How to use the theme builder
Enter your brand color (it anchors the hue and the mid-tone chroma), name the palette, and choose a lightness curve and target gamut. The 11-stop ramp updates live — click any swatch to copy its hex. Copy the @theme block into your Tailwind v4 globals.css and the bg-/text-/border- utilities are generated for you. The full configuration is encoded in the URL, so a palette is a shareable link.
Why OKLCH scales are better
A color scale needs even *perceptual* steps so that, say, 500 on white and 500 on a dark card read with comparable contrast. OKLCH delivers that because its lightness axis matches human perception. This tool fixes the hue, eases lightness across the ramp, and peaks chroma in the mid-tones — then clamps each stop into your chosen gamut with culori so it’s always displayable.
Frequently asked questions
How does Tailwind v4 handle custom colors?
Tailwind v4 defines theme tokens as CSS custom properties inside an `@theme` block in your CSS, rather than in a JavaScript config. A color like `--color-primary-500: oklch(0.62 0.19 256)` automatically generates utilities such as `bg-primary-500` and `text-primary-500`. This tool emits exactly that block — paste it into your `globals.css`.
Why generate the scale in OKLCH instead of HSL?
OKLCH is perceptually uniform: equal lightness steps look equally spaced to the eye, and a fixed chroma keeps saturation consistent across the ramp. HSL's lightness is not perceptual, so an HSL ramp produces uneven contrast — some stops look muddy, others wash out. An OKLCH ramp gives predictable, accessible contrast between stops.
What does the lightness curve do?
It controls how the 11 lightness values are distributed between the lightest (50) and darkest (950) stops. 'Linear' spaces them evenly; 'ease-in' and 'ease-out' bias the steps toward the light or dark end, which can give more usable mid-tones depending on your design. Hue stays fixed and chroma peaks around 500–600 either way.
Why are some stops marked as chroma-clamped?
Vivid colors at mid lightness can request more chroma than a display gamut can show. Rather than clip the RGB channels (which shifts the hue), each stop is chroma-clamped — chroma is reduced just enough to fit sRGB or Display P3 while preserving the hue and lightness. Choosing Display P3 keeps more saturation for P3-capable screens.
Can I use Display P3 colors in Tailwind?
Yes — `oklch()` values can exceed sRGB, and browsers render the wider-gamut color on P3-capable displays while falling back gracefully elsewhere. Pick the P3 gamut here to keep more chroma in the mid-tones; pick sRGB for the most conservative, universally-identical output.
Related tools
References
This tool’s color math is grounded in the following standards and primary sources.
- Tailwind CSS v4 — theme variables — Tailwind Labs — the @theme directive
- A perceptual color space for image processing (OKLab / OKLCH) — Björn Ottosson, 2020
- CSS Color Module Level 4 — W3C Candidate Recommendation
- culori — color library — Dan Burzo (MIT)
Spotted an error? Let us know — reader corrections are the best review this site gets.