Styling and theming
Tailwind v4 in CSS-first mode, the two-layer token rule, cn() and CVA, and why dark mode is off site-wide.
All styling config lives in one file, app/app.css, imported once at the top of app/root.tsx. There is no tailwind.config.js and no postcss.config; never add one.
Dark mode is off everywhere
app/routes/_layout.tsx resets the theme to light on every render, and every page with UI sits inside that layout. There is no theme toggle, so dark: classes and the .dark tokens never apply. Turning dark mode on means relaxing that effect first.
What lives where
| Need | Where | Example |
|---|---|---|
| Engine and plugins | Top of app/app.css | @import "tailwindcss", @plugin "@tailwindcss/typography" |
| Extra class sources | @source in app/app.css | @source "/node_modules/streamdown/dist/index.js" |
| Dark mode strategy | @custom-variant in app/app.css | dark (&:is(.dark *)), class based |
| Colors (raw values) | :root and .dark in app/app.css | --primary: oklch(...) |
| Colors, radii, animations as utilities | @theme inline block | --color-primary: var(--primary) |
| Fonts | Plain @theme block | --font-sans, --font-poppins, --font-display |
| Class merging | cn() in app/lib/utils.ts | twMerge(clsx(inputs)) |
| Component variants | cva() in app/components/ui/* | buttonVariants |
| Theme state | Zustand useTheme in app/components/providers/theme.provider.tsx | persisted as naalya-theme |
Keep these two lines
The @source line keeps the classes used by the streamdown markdown renderer; without it the AI chat loses its styling. The biome-ignore-all comment on line 1 stops Biome flagging the v4 at-rules. components.json has "config": "" on purpose: it tells shadcn there is no JS config.
Adding a color token
A color needs both layers. Miss the raw value and the utility resolves to nothing; miss the mapping and the utility doesn't exist.
Add the raw value to both :root and .dark, in OKLCH.
:root { --brand: oklch(0.62 0.19 25); }
.dark { --brand: oklch(0.70 0.17 25); }Map it in @theme inline so bg-brand, text-brand and the rest exist.
@theme inline { --color-brand: var(--brand); }inline makes the utility read the live variable, so flipping .dark re-themes it without a rebuild. A color in the plain @theme block would never switch.
The same pattern gives radii (--radius-2xl makes rounded-2xl) and animations (--animate-foo makes animate-foo). An animation needs both the --animate-* token and its @keyframes: the blob-float-1/2/3 keyframes have no token, so animate-blob-1 does not exist.
The dark palette swaps roles rather than darkening: in .dark, --primary takes the light theme's secondary blue and --secondary becomes yellow.
Composing classes and variants
cn() from @/lib/utils merges classes with last-wins rules, so a caller's className overrides the default:
cn("rounded-md px-4", isActive && "bg-primary", "px-8")
// "rounded-md bg-primary px-8"Eleven primitives in app/components/ui/ use CVA. To write a new one, copy the shape of button.tsx:
const fooVariants = cva(base, { variants, defaultVariants }).- Type props with
VariantProps<typeof fooVariants>. - Render
className={cn(fooVariants({ variant, size, className }))}so the caller can override. - Put
data-slot="foo"on the root element. - Export both the component and
fooVariants.
Use asChild (Radix Slot) to render a primitive as another element, for example <Button asChild><Link to="/contact">Contact</Link></Button>, instead of copying button classes onto a link.
Theming
Custom useTheme | next-themes | |
|---|---|---|
| Import from | @/components/providers/theme.provider | next-themes |
| Used by | The whole app; toggles .light or .dark on <html> | app/components/ui/sonner.tsx only |
| Effect | Drives every dark: class | No provider is mounted, so it does nothing useful |
Import the custom hook for anything theme related; importing the next-themes one silently does nothing.
To support both themes in a component, build from semantic tokens (bg-background, text-foreground, bg-card, border-border). They flip with .dark, usually with no dark: classes at all.
Fonts and prose
| Token | Font | Loaded by |
|---|---|---|
font-poppins | Poppins | Google Fonts @import in app/app.css; applied to body, so it is what you see |
font-sans | Inter | <link> in app/root.tsx |
font-display | Instrument Serif | <link> in app/root.tsx |
The prose class (typography plugin) styles long-form Sanity and markdown content on pages like blog-post.tsx and about.tsx. Use not-prose to escape it, and don't use it for app chrome.