In Tailwind CSS v3, blue-500 was #3b82f6. In v4 it is oklch(62.3% 0.214 259.815). That is not just a new notation for the same color: v4 redefined the default palette in OKLCH and made many shades more saturated than sRGB can show. If you copy v4 colors into a design tool, compare them with an old project, or add brand colors next to them, it helps to know what those numbers mean.

Reading an oklch() value

oklch(L C H) describes a color by lightness, chroma and hue, in the Oklab color space.

  • L, lightness: 0% is black and 100% is white. You can also write it as a number from 0 to 1. It is designed to track how light a color looks, not how much light the screen emits.
  • C, chroma: how far the color is from gray. 0 is fully neutral. There is no fixed maximum, but displayable colors stay below about 0.4. If you write chroma as a percentage, 100% means 0.4, not 1.
  • H, hue: an angle around the color wheel, in degrees. Unlike HSL, the angles do not match HSL hues; red sits near 25, not 0.
  • An optional alpha after a slash: oklch(62.3% 0.214 259.815 / 50%).

Tailwind's own 500 shades give a useful map of the hue angle: rose is about 16, red 25, orange 48, amber 70, yellow 86, lime 131, green 150, emerald 162, teal 183, cyan 215, sky 237, blue 260, indigo 277, violet 293, purple 304, fuchsia 322 and pink 354. The neutral families use very low chroma: slate-500 is oklch(55.4% 0.046 257.417), which is why it reads as a slightly blue gray, and neutral-500 is oklch(55.6% 0 0), with no hue at all.

Why OKLCH lightness beats HSL lightness

HSL's lightness is a property of the RGB numbers, not of what you see. Pure yellow, hsl(60 100% 50%), and pure blue, hsl(240 100% 50%), both have 50% lightness. Converted to OKLCH, the yellow is about L 96.8% and the blue about L 45.2%. One is nearly white; the other is dark enough for white text. That is why a palette built by keeping HSL lightness constant and rotating the hue never looks even.

hsl(60 100% 50%)
OKLCH L ≈ 96.8%
hsl(240 100% 50%)
OKLCH L ≈ 45.2%

In OKLCH, lightness and chroma are separate from hue, so you can make predictable changes: lower L to darken a color without it drifting toward another hue, lower C to mute it, or keep L and C and change H to get a second color with similar visual weight. Oklab was designed to keep hue steady while lightness and chroma change, which fixes the drift toward purple that blues show in the older CIELAB-based LCH.

Tailwind does not keep L identical across hues at the same step. Its 500 shades run from about 58.5% (indigo) to 79.5% (yellow). A saturated yellow cannot exist at low lightness; darken it enough and it turns olive or brown. So the steps are tuned per hue, and you should compare shades by their L values rather than by step number.

OKLCH lightness is not the same measurement as WCAG contrast, which uses relative luminance. Two colors with the same L can give different contrast ratios against white, so still check text pairs; the approach is covered in Contrast, in context.

Chroma, gamut and Display P3

A gamut is the range of colors a color space or a screen can produce. sRGB, which HEX and rgb() describe, is the smallest common one. Most recent phones and laptops show Display P3, which reaches further into saturated reds, greens and oranges. OKLCH is not tied to either: it can describe colors that a given screen cannot show.

Tailwind's v4 release notes say the palette moved from rgb to oklch to take advantage of the wider gamut and make colors more vivid where sRGB was limiting them. Converting the v4.3 palette ourselves, every shade falls inside Display P3, while many of the saturated ones, such as orange-500, green-500 and blue-500, sit outside sRGB. On a P3 screen those shades show at full strength. On an sRGB screen, the browser maps them to the nearest color it can show.

Maximum chroma also depends on lightness and hue. A chroma of 0.13 is comfortably inside sRGB for a mid-lightness violet, but the same chroma at 97% lightness is not. When you build a scale, the lightest and darkest steps need much less chroma than the middle ones.

Fallbacks for browsers and tools without OKLCH

Tailwind v4 documents Chrome 111, Safari 16.4 and Firefox 128 as the browsers its core depends on, and all of them support oklch(). If your project already uses v4, you do not need a fallback for the color function itself. You need one only when supporting older browsers outside v4's targets, or when a color has to leave CSS.

For CSS, write a HEX value first and the oklch() value after it. A browser that does not understand oklch() ignores that declaration and keeps the HEX one.

css
.button {
  background-color: #2b7fff;                         /* sRGB fallback */
  background-color: oklch(62.3% 0.214 259.815);      /* blue-500 */
}

/* Only push chroma beyond sRGB on screens that can show it */
.accent {
  color: oklch(60% 0.15 145);
}

@media (color-gamut: p3) {
  .accent {
    color: oklch(60% 0.22 145);
  }
}

Defining custom colors with @theme

In v4, colors live in CSS. Any variable in the --color-* namespace inside @theme creates matching utilities (bg-*, text-*, border-*, fill-* and so on) and is also emitted as a CSS variable you can use directly.

css
@import "tailwindcss";

@theme {
  --color-brand-50: oklch(97.5% 0.01 280);
  --color-brand-100: oklch(94.5% 0.022 280);
  --color-brand-200: oklch(89% 0.045 280);
  --color-brand-300: oklch(82% 0.085 280);
  --color-brand-400: oklch(73% 0.115 280);
  --color-brand-500: oklch(64% 0.13 280);
  --color-brand-600: oklch(55% 0.12 280);
  --color-brand-700: oklch(47% 0.105 280);
  --color-brand-800: oklch(39% 0.085 280);
  --color-brand-900: oklch(31% 0.065 280);
  --color-brand-950: oklch(22% 0.045 280);
}

This scale keeps the hue fixed at 280, steps lightness down in roughly even increments, and peaks chroma at 500. All eleven values are inside sRGB, so their HEX conversions are exact. White text on brand-600 (#6568b6) measures about 5:1, while brand-500 is too light for small white text. Check a scale like this with real text before settling on it.

A few related details:

  • Opacity modifiers work on custom colors. bg-brand-500/50 compiles to color-mix(in oklab, var(--color-brand-500) 50%, transparent), plus a fallback for browsers that cannot mix colors in OKLab.
  • To remove default colors you do not use, set their namespace to initial: --color-lime-*: initial;. To replace the whole palette, start @theme with --color-*: initial; and then define your own.
  • In plain CSS, use the variable: color: var(--color-brand-700);. To change the opacity of a variable inside CSS, Tailwind provides --alpha(var(--color-brand-700) / 10%).
  • Gradients in v4 interpolate in OKLab by default, so a gradient between two saturated colors is less likely to pass through a dull gray midpoint than with sRGB interpolation.

Tailwind v4's gradient utilities and interpolation modifiers are covered in the Tailwind gradients article.

Relative color syntax lets you derive a hover state from a token, such as oklch(from var(--color-brand-600) calc(l - 0.06) c h). It is newer than Tailwind's minimum browser targets, so check support for your audience, or define the hover shade as its own token.

Converting OKLCH to HEX

You still need HEX in places: the native color input only accepts #rrggbb, some design tools and email clients do not read oklch(), and many brand guidelines are written in HEX. For a color inside sRGB, conversion is exact. For a color outside it, there are two ways to get an sRGB value, and they can give visibly different results.

  • Clipping converts to RGB and then limits each channel to the 0 to 255 range. It is simple and fast, but because each channel is cut separately, the hue and lightness can shift.
  • Gamut mapping lowers chroma while keeping lightness and hue as stable as possible until the color fits. The result is less saturated but closer to the intended color. CSS Color 4 describes this approach for browsers.

The Color.js library gamut maps by default when it outputs HEX:

js
import Color from "colorjs.io";

const orange500 = new Color("oklch(70.5% 0.213 47.604)");
orange500.to("srgb").toString({ format: "hex" });

If you only need a quick value in a browser, drawing the color on a canvas and reading the pixel back gives a clipped sRGB value with no dependencies:

js
function cssColorToHex(color) {
  const ctx = document.createElement("canvas").getContext("2d");
  ctx.fillStyle = color;
  ctx.fillRect(0, 0, 1, 1);
  const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
  return "#" + [r, g, b].map((v) => v.toString(16).padStart(2, "0")).join("");
}

cssColorToHex("oklch(62.3% 0.214 259.815)"); // "#2b7fff"

Keep the oklch() value as the source of truth and treat HEX as an export. Converting back from a clipped HEX value will not return the original OKLCH color.

Using the GradientDeck Tailwind colors page

The Tailwind colors page lists the default v4.3 palette, generated from the installed tailwindcss package: the neutral families (slate, gray, zinc, neutral, stone, mauve, olive, mist and taupe) and the chromatic ones from red to rose, each with eleven steps from 50 to 950. Choose a copy format (color name, HEX, RGB, HSL or OKLCH) and click a swatch to copy that value. The OKLCH values match Tailwind's theme exactly. HEX, RGB and HSL are sRGB conversions, clipped where a shade is outside sRGB, so for shades like orange-500 they are the closest sRGB color rather than an exact match.

Copy the color name when you are working inside a Tailwind project, so the class keeps following the theme. Copy OKLCH when you need the value in plain CSS or another token file, and HEX only for tools that cannot read anything else.

References

MDN: oklch()

Tailwind CSS v4.0 release post

Tailwind CSS: colors

Tailwind CSS: compatibility

W3C: CSS Color Module Level 4

Color.js: output