Skip to content
Browse documentation

Theming

The components have no theme layer of their own. They read shadcn/ui’s CSS variables, so your colours and your dark mode apply as soon as they land.

The tokens they read

Change one in your global CSS and the components follow, in light and dark.

VariableIts role in shadcn/ui
--background--foregroundDefault background and text.
--primary--primary-foregroundPrimary actions. Usually your brand.
--muted--muted-foregroundMuted backgrounds and secondary text.
--accentHover and highlighted backgrounds.
--borderBorders.
--ringFocus rings.
--popover--popover-foregroundPopovers and menus.
--card--card-foregroundCards.
--destructiveDestructive actions.
--chart-1--chart-2--chart-3--chart-4--chart-5Chart series, in order. Grey in shadcn’s default theme: see Chart colours below.

Customise your theme

Colours, dark mode and fonts live in your global CSS, the same file shadcn init wrote. Anything else is a class in the component’s own source, which is yours once it is installed.

  1. 01

    Your brand colour

    Set --primary, the text on it and the focus ring, with a separate value for dark. Any colour format works.

    app/globals.css
    :root {  --primary: oklch(0.55 0.2 260);  --primary-foreground: oklch(0.99 0 0);  --ring: oklch(0.55 0.2 260);}.dark {  --primary: oklch(0.65 0.18 260);  --primary-foreground: oklch(0.99 0 0);  --ring: oklch(0.65 0.18 260);}
  2. 02

    Your neutrals

    Backgrounds, text greys and borders come from the same file.

    app/globals.css
    :root {  --background: oklch(0.99 0.004 90); /* a warmer page */  --foreground: oklch(0.25 0.01 90);  --muted: oklch(0.96 0.006 90);  --muted-foreground: oklch(0.5 0.01 90);  --border: oklch(0.9 0.008 90);}
  3. 03

    Or paste a whole shadcn theme

    Any theme made for shadcn/ui works, from shadcn’s themes or a generator like tweakcn, because these are the variables those themes set.

  4. 04

    A different colour for one section

    Variables set on an element apply to everything inside it, so a pricing section or a dashboard panel can carry its own brand.

    pricing.tsx
    <section style={{ "--primary": "#0f766e", "--ring": "#0f766e" } as React.CSSProperties}>  <PricingToggle value={billing} onValueChange={setBilling} /></section>
  5. 05

    Corners

    Corners are Tailwind classes in each component’s file. In a shadcn project rounded-sm to rounded-xl follow your --radius; to change any other, like rounded-full on a pill, edit the class.

  6. 06

    Status colours

    Error, success and warning colours are classes in the component’s file too. Replace them to use your theme’s.

    components/waitlist-field.tsx
    // components/waitlist-field.tsx, the "Enter a full email address" hint// beforeclassName="… text-red-600 … dark:text-red-400"// after: your theme's destructive colourclassName="… text-destructive …"
  7. 07

    Fonts

    Components inherit the font of the page they sit in; code and counters use font-mono. Set your fonts once, on body and in Tailwind’s --font-mono.

  8. 08

    One instance

    Every component takes className for its outer element: width, spacing or a one-off colour.

    settings.tsx
    <StatusButton className="w-full" status={status} onClick={save} />

Dark mode

It is shadcn’s: a .dark class on <html> swaps the variables and the components follow. Use next-themes or your own toggle.

Chart colours

Charts take their colours from five theme variables, in order. Set them and every chart follows.

A new project from shadcn init sets all five to shades of grey in its default theme, so charts start out grey: readable, but quiet. For colour, give them five hues, with a second set for dark mode. Paste these into the same file as your theme; they are the colours this site uses, checked so neighbouring series stay apart for colour-blind readers.

app/globals.css
:root {  --chart-1: #305dde; /* blue */  --chart-2: #e8743b; /* orange */  --chart-3: #1baf7a; /* green */  --chart-4: #8b6fe8; /* violet */  --chart-5: #e0a21b; /* amber */}.dark {  --chart-1: #5b82ea;  --chart-2: #d95926;  --chart-3: #199e70;  --chart-4: #9085e9;  --chart-5: #c98500;}

Order matters: the first series, slice or ring takes --chart-1, the next --chart-2, and so on. A chart that shows one measure uses one of them (the heatmap --chart-3, the live line chart --chart-1), and the blocks take their tints from the same five.

For one chart in its own colours, set the variables on an element around it, or pass a colour where the chart takes one: a donut slice’s color, or color on the heatmap and the live line chart.

spend.tsx
<div style={{ "--chart-1": "#0f766e", "--chart-2": "#f59e0b" } as React.CSSProperties}>  <DonutChart data={slices} /></div>

Try a brand

Three real components inside a box that sets only --primary, --primary-foreground and --ring, plus the light or dark set.

Pro

$29/mo
Billed monthly

Hear when the next release ships

Plan changes apply today.

app/globals.css
:root {  --primary: #305dde;  --primary-foreground: #ffffff;  --ring: #305dde;}.dark {  --primary: #4a76ec;  --primary-foreground: #ffffff;  --ring: #4a76ec;}