Skip to content

TL-M0-29 · Tailwind CSS in apps/web

Why: D35 adds Tailwind CSS v4 to apps/web for layout. TL-M0-08 made the app without it, so this step installs it and proves the pipeline works, without touching the design system. It adds only Tailwind's utilities, in a cascade layer of their own: no reset and no default theme, because opleet.css and tokens.css already supply both (D8). The Frontend Engineer then generates the token theme (design/opleet/theme.css) and imports it in app.css, in FE-M0-15, part of FE pack C; that step also replaces the breakpoints set here with the tokens' own.

ID TL-M0-29 · Level L0 · Run order row 25a · Issue #142

tailwindcss 4.3.3 is installed in apps/web. A utility class on a page produces CSS, an op-* class still wins over a utility, and typecheck, lint and build pass. Nothing under design/opleet or components/opleet has changed.

  • D35 is merged.
  • FE pack B (#16) is merged or not started, so the two don't touch app/layout.tsx at once.
  • You are in ~/opleet-v2/opleet on main, up to date, and git status --short prints nothing.

1 · A branch and the three packages, pinned

Section titled “1 · A branch and the three packages, pinned”
Terminal window
git switch main && git pull
git switch -c web/tailwind
pnpm --filter web add -D -E tailwindcss@4.3.3 @tailwindcss/postcss@4.3.3 postcss@8.5.29
Terminal window
cat > apps/web/postcss.config.mjs <<'EOF'
export default {
plugins: { "@tailwindcss/postcss": {} },
};
EOF

3 · The stylesheet: utilities in their own layer, and a small theme

Section titled “3 · The stylesheet: utilities in their own layer, and a small theme”

The @theme block holds only the breakpoints and the spacing unit. The token theme arrives later as a generated file, imported here by the Frontend Engineer.

app/app.css keeps its existing rule. The layer line and the import come first, so utilities sit in a layer; opleet.css, imported by app/layout.tsx outside any layer, therefore beats them.

Terminal window
cat > apps/web/app/app.css <<'EOF'
/* App-level layout only. Colours, type and components come from the design system (@ui/design).
Tailwind adds layout utilities only (D35): no reset, no default theme. */
@layer theme, base, components, utilities;
@import "tailwindcss/utilities.css" layer(utilities);
@theme {
--spacing: 0.25rem;
--breakpoint-sm: 40rem;
--breakpoint-md: 48rem;
--breakpoint-lg: 64rem;
--breakpoint-xl: 80rem;
}
html,
body {
min-height: 100dvh;
}
EOF

In biome.json at the repository root, add this next to "formatter" and "linter":

"css": { "parser": { "tailwindDirectives": true } },

This writes two utility classes into a small text file in apps/web/app, so the build has to generate them. Tailwind reads every file in apps/web that git doesn't ignore, so the file needs no import. It is removed in the same block, before anything is committed. (The first version of this block edited app/page.tsx with sed, which matched nothing after FE pack B, #142.)

Terminal window
echo 'flex gap-4' > apps/web/app/canary.txt
pnpm typecheck
pnpm lint
pnpm --filter web build
grep -rlF -e '.gap-4' apps/web/.next/static --include='*.css'
rm apps/web/app/canary.txt
Terminal window
git status --short
git add -A
git commit -m "build(web): add tailwind css for layout (d35)"
git push -u origin web/tailwind
gh pr create --fill
gh pr checks --watch

7 · Merge, and look at the design preview

Section titled “7 · Merge, and look at the design preview”
Terminal window
gh pr merge --squash --delete-branch
git switch main && git pull
NEXT_PUBLIC_DESIGN_PREVIEW=1 pnpm dev

Open http://localhost:3000/design-preview in light and dark, compare it with how it looked before the step, then press Ctrl+C.

  • Block 1: pnpm adds three devDependencies to apps/web and prints no "Ignored build scripts" warning.
  • Block 5: typecheck and lint pass; the build passes; grep prints at least one css file name (it looks for the .gap-4 rule, which only exists if Tailwind generated it). Biome says nothing about @theme.
  • Block 6: git status lists package.json, pnpm-lock.yaml, biome.json, apps/web/package.json, apps/web/postcss.config.mjs and apps/web/app/app.css, and nothing under apps/web/design or apps/web/components. No canary.txt. The checks pass.
  • Block 7: the preview looks the same as before: same fonts, same spacing, same glass panels in both themes.
Terminal window
git diff --stat HEAD~1 -- apps/web/design apps/web/components
grep -c "tailwind" apps/web/package.json

The first prints nothing. The second prints 2.

  • Biome fails to parse @theme: the "css" line from block 4 is missing or in the wrong place in biome.json. Paste the Biome output.
  • grep prints nothing: the build didn't see the classes. Check postcss.config.mjs is in apps/web, not the root, and paste the build output.
  • pnpm warns about ignored build scripts: paste the warning. Don't add anything to allowBuilds until a CTO session says which package.
  • The preview's fonts or spacing change: stop before merging. Something is overriding the design system; paste a screenshot to #142.
  • Block 6's git status shows canary.txt: block 5 stopped before its last line. Run rm apps/web/app/canary.txt and check again.

Before merging, delete the branch: git switch main && git branch -D web/tailwind. After merging, revert the squash commit with git revert <commit> on a branch and a pull request, and tell a CTO session so D35 and this page change with it.

Log each run as a comment on #142: the date, what you ran, and the output that mattered.