Styling

Styling

Write CSS files. There is no build configuration for them: the build finds every .css file under src/ and inlines it into the pages it reaches, so a page arrives with its styles and makes no second request for them.

Global stylesheets

A .css file outside routes/ — the starter's src/styles.css — reaches every page. Put your tokens, fonts and base typography there.

Section stylesheets

A .css file inside routes/ reaches only the pages in its directory and below it — the same reach a layout.tsx beside it has:

src/
├── styles.css              every page
└── routes/
    └── docs/
        ├── layout.tsx
        └── docs.css        /docs and every page under it, nothing else

Global stylesheets come first and a directory's come after, deeper directories last, so a section can override the rules it inherits. This site works that way: the landing page never downloads the docs' styles.

Note

A stylesheet directly in routes/ reaches every page, like a global one. The front page cannot have styles of its own that the rest of the site does not also receive.

CSS modules

A file named *.module.css is scoped. Import it, and its class names become unique to it:

import styles from "./Card.module.css";

export default function Card() {
  return <div className={styles.card}>…</div>;
}

A module's styles are included only on the pages that render a component importing it.

Fonts and images

Put them in public/ and refer to them from the site root: public/fonts/body.woff2 is url("/fonts/body.woff2").

Next: deploy.