Coming from Tailwind
Tailwind classes and their Kerf words side by side, what works differently, and how to move a page over.
The same page in both
<!-- Tailwind -->
<main class="mx-auto w-full max-w-5xl px-6 flex flex-col gap-4 md:grid md:grid-cols-3">
<a href="/start" class="inline-flex items-center rounded bg-blue-600 px-4 py-3 font-semibold text-white hover:bg-blue-700">Start</a>
<p class="text-gray-500">No account needed.</p>
</main>
<!-- Kerf -->
<main s="max 1024 pad-x 24 stack 16 md:grid 3">
<a href="/start" s="button primary">Start</a>
<p s="text-muted">No account needed.</p>
</main>
The ideas carry over: small words in the markup, phones first, prefixes for breakpoints and hover, and a stylesheet with only what you use. What changes is that the words come from your design system and the build checks them.
What works differently
- No arbitrary values. There's no
p-[13px]:pad 13is an error that names the nearest values. When you need something the system doesn't have, add it to the config or write it in your own CSS. - Spacing is in pixels.
pad 16is 16px, where Tailwind'sp-4is 4 × 4px. The default scale,0 4 8 12 16 24 32 48 64, is Tailwind's 0, 1, 2, 3, 4, 6, 8, 12 and 16. - Colours are roles, not shades. You write
text-mutedorbg-accent, nottext-gray-500. Each role has a light and a dark value, so there's nodark:prefix, and every pairing is checked for contrast. - Components are built in.
button primaryreplaces a dozen classes, with hover, focus ring and tap target included. Your own go in the config instead of@apply. - Text sizes follow your scale. The names are Tailwind's (
sm,lg,2xl), but the sizes come from your base and ratio. With the default 1.25,smis 12.8px; settext: { ratio: 1.125 }for steps closer to Tailwind's. - The same breakpoints.
sm: md: lg: xl:start at 640, 768, 1024 and 1280px by default, as in Tailwind, but inem, so they follow the reader's font size. Colours, components andhover:can't take one. - It's an attribute.
s=is compiled tok-classes in the HTML you ship, and leaves your ownclassalone. Classes that change at runtime can be written ask-classes directly.
Class by class
| Tailwind | Kerf |
|---|---|
p-4, px-6, py-2, pt-8, pb-8 | pad 16, pad-x 24, pad-y 8, pad-t 32, pad-b 32 |
flex flex-col gap-4 | stack 16 |
flex flex-wrap items-center gap-4 | row 16 |
grid grid-cols-3 gap-6 | grid 3 gap 24 |
col-span-2 | span 2 |
items-start, justify-between | align start, justify between |
mx-auto w-full max-w-5xl | max 1024 |
max-w-prose | measure |
min-h-dvh | screen |
grid place-items-center | center |
hidden md:block | hide md:show |
sticky top-0 | sticky |
overflow-x-auto | scroll |
text-sm, text-2xl | sm, 2xl |
font-bold, font-semibold, font-mono | bold, semibold, mono |
italic, uppercase | italic, uppercase |
text-left, text-center, text-right | text-start, text-center, text-end (they follow the reading direction) |
truncate, line-clamp-3 | truncate, clamp 3 |
flex-1 or grow, shrink-0 | grow, no-shrink |
text-gray-500, text-white | text-muted, on-accent |
bg-white dark:bg-gray-900 | bg-surface |
bg-blue-600 text-white | bg-accent on-accent |
border border-gray-200 | border-border |
bg-red-50 text-red-700 | bg-surface-danger text-danger, or alert danger |
rounded, rounded-full | round, round full |
shadow-sm, shadow-md, shadow-lg | shadow 1, shadow 2, shadow 3 |
aspect-video object-cover | ratio 16:9 cover |
hover:bg-gray-100 | hover:bg-surface-raised (also on keyboard focus) |
no-underline | no-underline (not on a link in a sentence) |
sr-only | visually-hidden |
prose (typography plugin) | prose |
p-[13px] | none: use the scale, or your own CSS |
Moving a page over
- Run
npx kerf init --hue <your brand hue>, and set your spacing and type scales in the config if they differ from the defaults. - Map your Tailwind colours to roles: the page background to
surface, body text totext, secondary text totext-muted, the brand colour toaccent. Kerf generates the dark values. - Rewrite one page or component at a time, from
classtos=, using the table above. Tailwind and Kerf can share a page while you move: Kerf's base styles have no specificity, so Tailwind's classes still win. - Run
npx kerf check. Every off-scale value and failing colour comes back with the nearest fix; a coding agent can work through them withkerf check --json.