How to style _layout.tsx?

Open
#3,828 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
deno, typescript
Domain
frontend

Research direction

Start by reproducing the reported behavior in a Fresh 2.3.3 project created with deno run -Ar jsr:@fresh/init, using the shown routes/index.tsx, routes/_layout.tsx, and CSS files. Run deno task build and inspect how _fresh/client/assets/_fresh-route___test-XXXX.css and server-entry-XXXX.css are generated and served; determine whether layout styles should be served and document or fix the behavior.

Written by the indexing model from the issue text.

Description

Hi, I am unable to style a layout.

Environment and reproduction steps:

  • Deno 2.8, Fresh 2.3.3
  • Create a new Deno project, created with deno run -Ar jsr:@fresh/init
  • Make sure you have the following files in the routes folder:

index.tsx

import { define } from "@/utils.ts";
import '@/assets/index.css';
export default define.page(function Home() {
  return (
    <div>Hello world</div>
  );
});

_layout.tsx

import { define } from "@/utils.ts";
import '@/assets/layout.css';
export default define.layout(function Layout({ Component }) {
  return (
    <div>
      <h1 class="layout">Layout</h1>
      <Component />
    </div>
  );
});

assets/layout.css

h1.layout {
    color: red;
}

assets/index.css

h1.test {
    color: green;
}

Result: h1 in index.tsx is colored green, but h1 in layout is not colored red - which is what I should expect.

After running deno task build I have the following files:
_fresh/client/assets/_fresh-route___test-XXXX.css

h1.test{color:green}

_fresh/client/assets/server-entry-XXXX.css

h1.layout{color:red}

So the styles are present. HOWEVER, that server-entry file is never served; so it won't do anything.

Question: is this a bug, should Fresh serve that server-entry.css? Or am I misunderstanding the way of styling?

  • No, I don't want Tailwind CSS.
  • This issue is written by a human
  • Claude and other AIs were unable to solve this problem

Can anyone help? And explain to me what that server-entry CSS file is?

Dominant language
TypeScript
Stars
13.8k
Forks
757
Avg merge
3m
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from freshframework/fresh

All issues in freshframework/fresh

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.