Want to build your theme visually? Use shadcn-templ Create to preview colors, radius, fonts, and icons, then generate a preset for your project.
We use and recommend CSS variables for theming.
This gives you semantic theme tokens like background, foreground, and primary that components use by default. Override those tokens in your CSS to change the look of your app without rewriting component classes.
To use CSS variables for theming, set tailwind.cssVariables to true in your components.json file. This is the default.
Tailwind maps these tokens into utilities like bg-background, text-foreground, border-border, and ring-ring.
Dark mode works by overriding the same tokens inside a .dark selector. See the dark mode docs for adding the theme script and toggling the .dark class.
Token Convention
We use semantic background and foreground pairs. The base token controls the surface color and the -foreground token controls the text and icon color that sits on that surface.
The background suffix is omitted for the surface token. For example, primary pairs with primary-foreground.
Given the following CSS variables:
The background color of the following component will be var(--primary) and the foreground color will be var(--primary-foreground).
Theme Tokens
These tokens live in your CSS file under :root and .dark.
The chart tokens are covered in more detail in the Chart theming docs.
Radius Scale
--radius is the base radius token for your theme.
We derive a small radius scale from it so components can use consistent corner sizes while still sharing a single source of truth.
This means:
radius-lgis the base value.- Smaller radii scale down from
--radius. - Larger radii scale up from
--radius. - Changing
--radiusupdates the entire radius scale.
Adding New Tokens
To add a new token, define it under :root and .dark, then expose it to Tailwind with @theme inline.
You can now use bg-warning and text-warning-foreground in your components.
Base Colors
tailwind.baseColor controls the default token values generated for your project when you run init or use a preset. Pick one on shadcn-templ Create to generate a theme with it.
The available base colors are: Neutral, Stone, Zinc, Mauve, Olive, Mist, and Taupe.
Default Theme CSS
The following is the full default neutral theme scaffold. Copy it into your global CSS file and adjust the tokens as needed.