Design tokens with Tailwind 4
Whether or not a project uses Tailwind, I keep design decisions (colours, surfaces, spacing) in CSS custom properties:
/* tokens */
:root { --brand: oklch(0.55 0.12 150); --surface: #fff; }
.forest-dark { --brand: oklch(0.72 0.14 150); --surface: #0b0f0c; }
/* Tailwind 4 maps tokens to utilities */
@theme inline {
--color-brand: var(--brand);
--color-surface: var(--surface);
}
Components use bg-surface text-brand; themes swap variables. The same approach let Ekonavi’s apps share forest and earthy themes, each with light and dark variants, from one package.
A shared theme package
The @ekonavi/theme package deliberately ships no compiled CSS. It exports tokens, theme classes and base-layer rules, and each consuming app tells Tailwind to scan the package. That avoids two common multi-app problems: duplicated utility CSS, and one app’s classes overriding another’s.
When I write plain CSS instead
On editorial sites with bespoke layouts, scroll choreography and per-section art direction (Eastern Condiments, ORVAS, Fresh Can), I usually write scoped component CSS with design tokens. For hand-built layouts, I find the cascade easier to follow than long utility strings.