Set the tokens under :root and .dark in your CSS file; hex works, and accent is the hover color
How to change shadcn/ui theme colors
You change shadcn/ui theme colors by editing the CSS variables in your stylesheet, located in app/globals.css in shadcn/ui's theming docs, under :root for light mode and .dark for dark mode. To update the theme, set values for --primary, --background, --accent and their companion -foreground tokens. To choose a palette before editing code, load your deployed site into Recolor (recolor.page) using the app, press Space to cycle through color combinations, and check the contrast of each swatch live on your page.
Last updated
| Token | What it controls, per the docs | A pick from the default palette |
|---|---|---|
--background / --foreground | The app's background and its default text | White with #264653 text, 10.08:1 |
--primary / --primary-foreground | The default Button, selected states and badges | #264653 with white text, 10.08:1 |
--secondary / --secondary-foreground | Secondary buttons and supporting surfaces | #e9c46a with #264653 text, 6.03:1 |
--accent / --accent-foreground | Hover, focus and active surfaces: ghost buttons, menu highlights, hovered rows | #f4a261 with #264653 text, 4.89:1 |
--ring | Focus rings and outlines | #2a9d8f |
--chart-1 to --chart-5 | The default chart palette | The five colors in order |
Where shadcn/ui keeps its colors
Setting tailwind.cssVariables: true in components.json, which is the default setting, turns on theming
through CSS variables. The tokens come in paired values. The base token defines a surface color, while the
corresponding -foreground token defines the color of the text and icons placed on top of that surface.
An @theme inline block maps each token directly into Tailwind CSS, as with --color-primary: var(--primary);, which generates the bg-primary utility class. Dark mode overrides these same token values
inside the .dark selector block.
The --accent token is not intended for your brand accent color. According to shadcn/ui's theming docs,
--accent provides surface colors for hover, focus and active states, such as ghost button backgrounds and
dropdown menu highlights.
The tailwind.baseColor setting in components.json only sets the initial values written by init or when
applying a preset. After initialization, you edit the CSS variable tokens directly. The shadcn/create tool
previews colors, border radius, fonts and icons on shadcn components and exports a preset, which Recolor does
not do. Instead, Recolor displays full palettes directly on your own live pages.
Try the palette on your deployed site first
To test colors on your actual layout, paste your deployed web address into Recolor and press Space to generate new palettes. When you find a color you want to keep, lock it in place with L.
Each color swatch displays its contrast ratio against black and white text, marked against the 4.5:1 requirement for the WCAG AA standard. For complete relationship details across all colors, the contrast matrix shows every color pair.
Recolor reads tokens as CSS variables, including oklch values. A Tailwind v3 project using bare HSL numbers
also works, reading values through hsl(var(--primary)) as explained in how it works.
A localhost address cannot be loaded by Recolor. To test local work, deploy a preview build or use the steps for loading a page by uploading a saved HTML file with its asset base URL. Embedded media, including photos, video and canvas elements, keep their original colors during repainting.
Setting the tokens in app/globals.css
shadcn/ui's Tailwind v4 docs write colors using oklch values, such as --primary: oklch(0.205 0 0);. Hex
format works as well, since Tailwind CSS's colors docs set theme colors in hex and the @theme inline
directive passes each value directly through the var() function.
/* app/globals.css */
:root {
--background: oklch(1 0 0);
--foreground: #264653;
--primary: #264653;
--primary-foreground: #ffffff;
--secondary: #e9c46a;
--secondary-foreground: #264653;
--accent: #f4a261;
--accent-foreground: #264653;
--ring: #2a9d8f;
--chart-1: #264653;
--chart-2: #2a9d8f;
--chart-3: #e9c46a;
--chart-4: #f4a261;
--chart-5: #e76f51;
}.dark {
--background: #264653;
--foreground: #ffffff;
--primary: #e9c46a;
--primary-foreground: #264653;
}Contrast ratios determine where each color belongs. In the light theme values above, white text on #264653
reads 10.08:1, #264653 text on #e9c46a reads 6.03:1, and #264653 on #f4a261
reads 4.89:1. Because #2a9d8f reads 3.32:1 with white text and 6.32:1 with black
text, it fails the 4.5:1 threshold for white text and serves as the focus ring token rather than a surface,
following the rules for black or white text.
What Recolor's export gives you
The CSS variables and Tailwind v4 options in exports output --color-1 through --color-5
along with --color-primary, --color-secondary and --color-accent.
Because shadcn/ui already defines these role names in its @theme inline block, do not paste the exported
code block directly alongside your existing theme. Instead, copy each generated hex code into its
corresponding token in app/globals.css. The five numbered color lines can be transferred into your
stylesheet by manually renaming --color-1 through --color-5 to --chart-1 through --chart-5.
Common questions
Do I have to write shadcn/ui colors in oklch?
No. Hex values work because the @theme inline block passes each token value directly through to Tailwind CSS utilities as written.
Is --accent the brand's accent color?
No. The docs assign --accent to interactive states, providing background colors for hover, focus, ghost buttons and menu highlights.
Does changing baseColor in components.json recolor an existing project?
No. That setting only controls the values generated during init or preset creation. Existing projects require editing the tokens in CSS.
Can Recolor load my dev server on localhost?
No. Recolor only loads public URLs. You can test local work by deploying a preview URL or uploading the saved page.
Is it free?
Yes. Loading a web page, generating palettes and every export format are free, without an account; see pricing.
Sources
- shadcn/ui's theming docs ui.shadcn.com
- shadcn/ui's Tailwind v4 docs ui.shadcn.com
- Tailwind CSS's colors docs tailwindcss.com