@cf/ui

Principles

The handful of ideas the code already follows, written down so new work follows them too.

Semantic tokens over raw values

Components ask for a role, not a colour. bg-primary means "the strongest fill", and theme.css decides that is Radix gray-12 in light mode. That is what lets dark mode, and anyone else's palette, work without touching component code.

Inherit type, don't own it

The site sets its typeface on body. Components set sizes and weights (text-sm, font-medium) and nothing else, so they look native wherever they're dropped. The one exception is Kbd, which uses font-mono because a keycap should read as a key.

Subtract, don't adapt

On small screens I remove things rather than translate them. A tooltip that explains a shortcut has nothing to offer a phone, so it goes. What remains still gets touch treatment: 16px inputs so iOS doesn't zoom, taller menu items below md, and touch-target on isolated small controls.

The source is the documentation

This registry copies source, so the source has to explain itself. button.tsx says why hit-area expansion is opt-in; switch.tsx says why the track uses foreground and background instead of --input; theme.css says why destructive skips Radix step 9. These pages summarise those comments; when they disagree, the code is right and this page is stale.

Honest about gaps

Some components still carry stock shadcn classes I haven't reconciled, such as dark: opacity tweaks and two different focus ring weights. I'd rather list those than hide them.

Rules

The same rules ship in DESIGN.md and the MCP server, for the agents building with this.

  • must

    Colour components with semantic utilities such as bg-primary, text-muted-foreground and border-border, never raw palette values like bg-gray-3 or hex codes.

    semantic-tokens-only

  • must

    Do not set a font-family in a component; let it inherit from the page, with font-mono in Kbd as the only exception.

    inherit-typeface

  • should

    Below md, remove affordances that only exist for a keyboard or pointer (keycap hints, hover tooltips, shortcut rows) instead of shrinking them or inventing touch equivalents.

    subtract-dont-adapt

  • should

    When a component departs from the stock shadcn version, leave a comment in the source saying why.

    The source is what gets copied into your repo, so the reasoning has to travel with it.

    comment-the-why