kanso/ui

Getting started

Theming

Every colour is a CSS variable. Change a variable and every component follows.

Components never use raw colours such as bg-zinc-900. They use semantic names such as bg-primary and text-muted-foreground, which Tailwind maps to the variables below.

Tokens

TokenUsed for
background / foregroundPage surface and default text.
card, popoverRaised surfaces: cards, menus, dialogs.
primaryThe main action. Near-black in light mode, near-white in dark.
secondary, muted, accentQuiet fills for secondary buttons, hover states and disabled areas.
muted-foregroundSupporting text: descriptions, placeholders, captions.
destructive, successThe only two hues by default. Used sparingly.
border, input, ringHairlines, field borders and the focus ring.
--radiusOne number. sm, md, lg and xl are derived from it.

Adding a colour

Define it for both modes, then expose it to Tailwind inside @theme inline.

:root  { --warning: oklch(0.8 0.15 85); }
.dark  { --warning: oklch(0.75 0.14 85); }

@theme inline {
  --color-warning: var(--warning);
}

Now bg-warning, text-warning and border-warning/30 all work.

Dark mode

The site toggles a .dark class on <html> with next-themes. Tailwind is told to use that class:

@custom-variant dark (&:where(.dark, .dark *));

Radius

Set --radius once. 0rem gives sharp corners, 0.75rem gives soft ones. Try it in the theme builder.