Skip to content

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 13 is 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 16 is 16px, where Tailwind's p-4 is 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-muted or bg-accent, not text-gray-500. Each role has a light and a dark value, so there's no dark: prefix, and every pairing is checked for contrast.
  • Components are built in. button primary replaces 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, sm is 12.8px; set text: { 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 in em, so they follow the reader's font size. Colours, components and hover: can't take one.
  • It's an attribute. s= is compiled to k- classes in the HTML you ship, and leaves your own class alone. Classes that change at runtime can be written as k- classes directly.

Class by class

TailwindKerf
p-4, px-6, py-2, pt-8, pb-8pad 16, pad-x 24, pad-y 8, pad-t 32, pad-b 32
flex flex-col gap-4stack 16
flex flex-wrap items-center gap-4row 16
grid grid-cols-3 gap-6grid 3 gap 24
col-span-2span 2
items-start, justify-betweenalign start, justify between
mx-auto w-full max-w-5xlmax 1024
max-w-prosemeasure
min-h-dvhscreen
grid place-items-centercenter
hidden md:blockhide md:show
sticky top-0sticky
overflow-x-autoscroll
text-sm, text-2xlsm, 2xl
font-bold, font-semibold, font-monobold, semibold, mono
italic, uppercaseitalic, uppercase
text-left, text-center, text-righttext-start, text-center, text-end (they follow the reading direction)
truncate, line-clamp-3truncate, clamp 3
flex-1 or grow, shrink-0grow, no-shrink
text-gray-500, text-whitetext-muted, on-accent
bg-white dark:bg-gray-900bg-surface
bg-blue-600 text-whitebg-accent on-accent
border border-gray-200border-border
bg-red-50 text-red-700bg-surface-danger text-danger, or alert danger
rounded, rounded-fullround, round full
shadow-sm, shadow-md, shadow-lgshadow 1, shadow 2, shadow 3
aspect-video object-coverratio 16:9 cover
hover:bg-gray-100hover:bg-surface-raised (also on keyboard focus)
no-underlineno-underline (not on a link in a sentence)
sr-onlyvisually-hidden
prose (typography plugin)prose
p-[13px]none: use the scale, or your own CSS

Moving a page over

  1. Run npx kerf init --hue <your brand hue>, and set your spacing and type scales in the config if they differ from the defaults.
  2. Map your Tailwind colours to roles: the page background to surface, body text to text, secondary text to text-muted, the brand colour to accent. Kerf generates the dark values.
  3. Rewrite one page or component at a time, from class to s=, 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.
  4. Run npx kerf check. Every off-scale value and failing colour comes back with the nearest fix; a coding agent can work through them with kerf check --json.