Skip to content

Variants & colours

Recolour a whole region with one CSS variable, pick a tone for a status, add a variant of your own with cva, or override a single class with className.

On this page

Recolour a region

Core components take their single highlight from --kn-accent and, on top of it, --kn-accent-foreground. Neither is set by default: the components fall back to --primary and --primary-foreground, so nothing changes until you set them. Set them on any element, a card, a section or :root, and everything inside follows. The Badge, Tag and Alert accent tone stay indigo until you do.

AccentSolidReview Live
Build
64%
Region recoloured
Everything above reads --kn-accent from this container.
TSX
<section className="[--kn-accent:oklch(0.54_0.23_292)] [--kn-accent-foreground:oklch(0.985_0_0)]">
  <Button>Deploy</Button>
  <Progress label="Build" value={64} />
  <Switch defaultChecked label="Notify me" />
</section>

/* or for the whole app, in your CSS */
:root { --kn-accent: oklch(0.54 0.23 292); --kn-accent-foreground: oklch(0.985 0 0); }
.dark { --kn-accent: oklch(0.72 0.17 292); }

Tone

Components that show a status take tone: neutral, accent, success, warning or danger. Badge, Tag and Progress also have info. Each tone is correct in light and dark. accent follows --kn-accent; the others are fixed signal colours.

neutralaccentsuccesswarningdanger
neutral accent success warning danger
ComponentPropValuesNotes
Badge, Tagtoneneutral, accent, info, success, warning, dangerExisting prop. accent reads --kn-accent.
Alerttoneneutral, accent, info, success, warning, dangerThe icon takes the tone; the surface stays a plain card.
Progresstoneneutral, accent, info, success, warning, dangerneutral and accent both follow --kn-accent.
Status Dottoneneutral, accent, success, warning, dangerWins over state for the colour; the pulse still follows state.
Segmented Controltoneneutral, accentaccent fills the chosen segment.
Button, Switch, Checkbox - - Follow --kn-accent with no prop.

Add a variant of your own

Each core component exports its look as a class-variance-authority map: buttonVariants, progressVariants, alertVariants, statusDotVariants, switchVariants, checkboxVariants and segmentedThumbVariants. The files are yours after install, so add an entry and use it.

components/ui/knowns/button.tsx
const VARIANT: Record<ButtonVariant, string> = {
  primary: "...",
  // your own
  brand: "bg-fuchsia-600 text-white not-disabled:hover:bg-fuchsia-600/90",
};
export type ButtonVariant = "primary" | "secondary" | "ghost" | "destructive" | "quiet" | "brand";

<Button variant="brand">Upgrade</Button>

// on a link, without a Button
<a className={buttonVariants({ variant: "brand", size: "lg" })} href="/pricing">Upgrade</a>

Override with className

cn in lib/knowns/utils.ts is clsx plus tailwind-merge, so a class you pass always beats the component’s own bg-*, text-*, rounded-* and p-*. Variants such as dark: and hover: are kept apart.

Custom badge
TSX
<Button className="rounded-full bg-emerald-600 px-5 text-white">Rounded and green</Button>

Chart colours

Chart series take --chart-1 to --chart-5 and fall back to the built-in palette, so setting them on :root or on a container restyles every chart inside. See Theming for the full token list.

Need help?

Stuck on Variants & colours, or found something off? We read every message.