Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIGetting startedReact

Theming

Every color and the corner radius is a CSS variable with the name shadcn/ui gives it. Change a value and every component follows.

How tokens pair

Most tokens come in twos: a surface such as --primary and the color of text and icons on it, --primary-foreground. A component that paints bg-primary writes its label in text-primary-foreground, so a theme only has to keep each pair readable. A few tokens stand alone: --border, --input and --ring (the focus outline), the five chart colors, and --radius.

The values live in two blocks of your stylesheet: :root holds the light ones and .dark the dark ones (Dark mode). The components never name a color; they name a token.

Tokens

The theme maps each token to a Tailwind CSS color with @theme inline, so --color-primary gives bg-primary, text-primary, border-primary and the rest. This table is read from that mapping in packages/ui/tokens/base.css, with the neutral theme's values:

TokenTailwind CSSLightDark
--background--color-backgroundoklch(1 0 0)oklch(0.145 0 0)
--foreground--color-foregroundoklch(0.145 0 0)oklch(0.985 0 0)
--card--color-cardoklch(1 0 0)oklch(0.205 0 0)
--card-foreground--color-card-foregroundoklch(0.145 0 0)oklch(0.985 0 0)
--popover--color-popoveroklch(1 0 0)oklch(0.205 0 0)
--popover-foreground--color-popover-foregroundoklch(0.145 0 0)oklch(0.985 0 0)
--primary--color-primaryoklch(0.205 0 0)oklch(0.922 0 0)
--primary-foreground--color-primary-foregroundoklch(0.985 0 0)oklch(0.205 0 0)
--secondary--color-secondaryoklch(0.97 0 0)oklch(0.269 0 0)
--secondary-foreground--color-secondary-foregroundoklch(0.205 0 0)oklch(0.985 0 0)
--muted--color-mutedoklch(0.97 0 0)oklch(0.269 0 0)
--muted-foreground--color-muted-foregroundoklch(0.556 0 0)oklch(0.708 0 0)
--accent--color-accentoklch(0.97 0 0)oklch(0.269 0 0)
--accent-foreground--color-accent-foregroundoklch(0.205 0 0)oklch(0.985 0 0)
--destructive--color-destructiveoklch(0.577 0.245 27.325)oklch(0.704 0.191 22.216)
--border--color-borderoklch(0.922 0 0)oklch(1 0 0 / 10%)
--input--color-inputoklch(0.922 0 0)oklch(1 0 0 / 15%)
--ring--color-ringoklch(0.708 0 0)oklch(0.556 0 0)
--chart-1--color-chart-1oklch(0.87 0 0)oklch(0.87 0 0)
--chart-2--color-chart-2oklch(0.556 0 0)oklch(0.556 0 0)
--chart-3--color-chart-3oklch(0.439 0 0)oklch(0.439 0 0)
--chart-4--color-chart-4oklch(0.371 0 0)oklch(0.371 0 0)
--chart-5--color-chart-5oklch(0.269 0 0)oklch(0.269 0 0)
--sidebar--color-sidebaroklch(0.985 0 0)oklch(0.205 0 0)
--sidebar-foreground--color-sidebar-foregroundoklch(0.145 0 0)oklch(0.985 0 0)
--sidebar-primary--color-sidebar-primaryoklch(0.205 0 0)oklch(0.488 0.243 264.376)
--sidebar-primary-foreground--color-sidebar-primary-foregroundoklch(0.985 0 0)oklch(0.985 0 0)
--sidebar-accent--color-sidebar-accentoklch(0.97 0 0)oklch(0.269 0 0)
--sidebar-accent-foreground--color-sidebar-accent-foregroundoklch(0.205 0 0)oklch(0.985 0 0)
--sidebar-border--color-sidebar-borderoklch(0.922 0 0)oklch(1 0 0 / 10%)
--sidebar-ring--color-sidebar-ringoklch(0.708 0 0)oklch(0.556 0 0)
--radius--radius-*0.625rem·

A dot in the Dark column means the token keeps its light value in dark mode.

Radius

One value, --radius, sets every corner. The rounded utilities are steps of it, so a rounder or squarer theme changes one line:

UtilityValue
rounded-smcalc(var(--radius) * 0.6)
rounded-mdcalc(var(--radius) * 0.8)
rounded-lgvar(--radius)
rounded-xlcalc(var(--radius) * 1.4)
rounded-2xlcalc(var(--radius) * 1.8)
rounded-3xlcalc(var(--radius) * 2.2)
rounded-4xlcalc(var(--radius) * 2.6)

Install the theme

An app that ran shadcn init already has these names and keeps its own values. Any other app adds the theme item, which writes the tokens, the @theme inline mapping and the base styles into its stylesheet:

npx shadcn@4.23.0 add https://hamur.dev/r/react/theme-neutral.json

Add a token

Give the token a value in both modes, then map it in @theme inline. Tailwind CSS then has bg-warning and text-warning-foreground:

:root {
  --warning: oklch(0.84 0.16 84);
  --warning-foreground: oklch(0.28 0.07 46);
}
.dark {
  --warning: oklch(0.41 0.11 46);
  --warning-foreground: oklch(0.99 0.02 95);
}

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