Styling

5:56 film

After this film you canstyle the app with CSS Modules, global CSS and Tailwind.

Exercise

Download the exercise (a zip). Unzip it, read exercise.md, then in exercise/ run npm install and node check.mjs. The checker runs a real build and says PASS or FAIL for each criterion.

Recall

Answer each one out loud before you open it.

  1. Carol's admin stylesheet turned the shop's price red. Why?

    Next.js currently keeps a stylesheet on the page as you navigate, so a global rule from one page reaches the next, until a reload.

  2. Where does each kind of style go?

    Truly global rules in one global CSS file imported in the root layout; most component styling in Tailwind classes on the element; custom scoped CSS in a CSS Module.

  3. Why can't two .badge classes in two CSS Modules collide?

    Each module's class names are made unique when it's built.

Docs this film covers