DevTools Logo

shadcn/ui Theme Generator

shadcn/ui Theme Generator

Generate custom shadcn/ui themes with CSS variables for light and dark mode. Copy-paste into your globals.css.

Theme Presets

Colors

#3b82f6
#6b7280
#8b5cf6
#f1f5f9
#ef4444

Border Radius

0.5rem

Examples

Convert the Blue preset primary

Input
#3b82f6
Output
217 91% 60%

The rounded HSL channels become the light-mode --primary value; the dark primary uses the same hue and saturation at 55% lightness.

Convert a Green primary

Input
#22c55e
Output
142 71% 45%

Because the lightness is below 50%, the light theme pairs this primary with a near-white foreground.

Convert the Slate preset primary

Input
#64748b
Output
215 16% 47%

The generator rounds the converted channels to integers before placing them in CSS custom properties.

About this tool

The shadcn/ui Theme Generator converts five chosen hex colors into HSL-channel CSS custom properties for light and dark interfaces. It emits the classic background, foreground, card, popover, primary, secondary, muted, accent, destructive, border, input, ring and radius tokens inside an @layer base block.

Choose one of six presets or adjust Primary, Secondary, Accent, Muted and Destructive with native color pickers. The converter rounds hue, saturation and lightness to whole numbers, derives foreground colors with a lightness heuristic, and creates darker variants by clamping or offsetting the selected lightness values.

The side-by-side preview helps compare the generated light and dark palettes before copying the CSS into globals.css. Because foreground selection is not a contrast audit, verify important text and controls against your accessibility targets after generation.

How to use

  1. Start from a preset

    Choose Default, Blue, Green, Orange, Rose or Slate to load a coordinated starting palette and radius.

  2. Tune the semantic colors

    Use the five color pickers to adjust primary actions, secondary surfaces, accents, muted surfaces and destructive states.

  3. Adjust the radius

    Move the radius slider from 0 to 2rem in 0.125rem steps and inspect the simulated controls in both previews.

  4. Copy the CSS

    Review the generated :root and .dark token blocks, copy them, and integrate them into the base layer of globals.css.

Use cases

Bootstrapping a new shadcn/ui application

Generate a coherent initial token set before building components and page layouts.

Creating branded light and dark modes

Translate brand colors into both theme blocks while keeping the same semantic token names.

Prototyping palette alternatives

Switch presets and color inputs quickly to compare visual directions without hand-editing dozens of CSS variables.

Standardizing border radius

Set one shared radius token and preview how it affects buttons, panels and other rounded surfaces.

Common mistakes

Mistake:Treating generated foreground colors as guaranteed accessible.

Fix:Measure contrast for text, icons and controls; the generator uses only a simple lightness threshold.

Mistake:Pasting the channel values into CSS as standalone colors.

Fix:Consume tokens in the convention expected by the app, commonly hsl(var(--primary)), because values such as 217 91% 60% are HSL channels.

Mistake:Expecting every modern shadcn token to be generated.

Fix:Add any project-specific chart, sidebar or status tokens manually after copying the fixed token set.

Mistake:Assuming hex-to-HSL conversion is lossless.

Fix:Expect small differences because hue, saturation and lightness are rounded to whole numbers.

Frequently asked questions

References & standards