OKLCH Interpolation in CSS Gradients

Build linear, radial, and conic CSS gradients with a visual editor. Drag color stops, pick presets, and copy ready-to-use CSS, Tailwind, or custom property output.

OKLCH Interpolation in CSS Gradients

The in oklch modifier routes CSS gradient interpolation through a perceptually uniform color space where equal numerical distances correspond to equal perceived color differences, eliminating the grey midpoints that sRGB produces between complementary hues1. Standard sRGB interpolation blends by mixing raw channel values, which often passes through a neutral grey in the middle of the transition. The OKLCH model describes color as L (lightness, 0 to 1), C (chroma, 0 to roughly 0.4), and H (hue angle, 0 to 360).

Writing linear-gradient(in oklch, blue, orange) produces a vivid midpoint instead of the dull sRGB path2. Consequently, OKLCH interpolation improves gradients between any two hues separated by more than about 90 degrees on the hue wheel. Building on this, browsers that support OKLCH interpolation (Chrome 111+, Firefox 113+, Safari 16.4+) handle gamut clipping automatically when chroma values exceed the display's coverage.

What this page covers

  • in oklch modifier routes interpolation through the OKLCH perceptual color space
  • Browser support Chrome 111+, Edge 111+, Firefox 113+, Safari 16.4+

Opens the CSS Gradient Builder with this page's checklist shown at the top of the tool.

Open in the tool →

The OKLCH perceptual model

OKLCH defines color in three axes1. L represents lightness from 0 (black) to 1 (white). C represents chroma: 0 is achromatic (grey) and values above roughly 0.37 land outside the sRGB gamut on most displays, in the wider P3 or Rec2020 range. H is the hue angle in degrees, running from red at 0 through yellow, green, cyan, blue, and back to red at 360. Together these three values describe any visible color with a structure that matches how human vision perceives differences between colors, making it a powerful tool for defining gradients that look smooth and uniform across their entire length.

Why OKLCH is perceptually uniform

Perceptual uniformity means that moving C by 0.05 produces the same perceived color change regardless of where on the hue wheel the starting color sits3. sRGB does not have this property: equal channel increments produce unequal perceptual steps. Consequently, gradients defined with OKLCH stops maintain consistent perceived saturation and lightness throughout the transition.

Choosing gradient stops in OKLCH allows designers to specify hue distance rather than trial-and-error channel values, producing more predictable results across different hue pairings. Because the lightness axis in OKLCH corresponds closely to perceived brightness, you can create gradients that maintain consistent perceived intensity across their entire length simply by keeping the L value constant and varying only the hue angle.

How sRGB produces grey midpoints and OKLCH avoids them

Between blue (approximately hsl(240,100%,50%)) and orange (approximately hsl(30,100%,50%)), the sRGB midpoint is hsl(135,0%,50%): fully desaturated grey3. The raw channel mix passes through zero chroma at the midpoint between these complementary hues. OKLCH interpolation travels the shortest angular path between the two hue angles rather than mixing channels arithmetically. For monochromatic gradients or transitions between adjacent hues, the visual difference between sRGB and OKLCH interpolation is negligible, which means the in oklch modifier is most valuable for gradients that span a wide hue range such as blue-to-orange or green-to-magenta.

The in oklch modifier applies to the entire gradient function, not individual stops. Writing linear-gradient(in oklch, blue, orange) processes all stops and their intermediate blending in OKLCH. Yet the modifier does not change the declared stop colors: blue and orange still specify the endpoints. The difference is only in how the browser computes the intermediate values. Furthermore, when two hues are close on the OKLCH wheel, the difference between sRGB and OKLCH interpolation is small; the grey midpoint issue is most visible for hue separations greater than roughly 90 degrees. For monochromatic gradients or transitions between adjacent hues, the visual difference between sRGB and OKLCH interpolation is negligible, which means the in oklch modifier is most valuable for gradients that span a wide hue range such as blue-to-orange or green-to-magenta.

Gamut clipping in practice

High-chroma OKLCH stops may specify colors outside the sRGB triangle. oklch(0.7 0.4 250) is a vivid blue that exceeds sRGB on most displays. Browsers clip these colors to the nearest sRGB equivalent when rendering on sRGB displays, typically by reducing chroma until the color falls within gamut.4 Colors clipped to sRGB appear less saturated than intended on sRGB displays but render correctly on P3 displays such as the MacBook Pro M4, iPhone 17 Pro, and Samsung Galaxy S25.

Designing for sRGB and P3 displays

Colors clipped to sRGB appear less saturated than intended on sRGB displays but render correctly on P3 displays (MacBook Pro M4, iPhone 17 Pro, Samsung Galaxy S25). To avoid unexpected clipping, keep chroma below 0.37 for universal sRGB compatibility. For P3-aware design, use chroma values up to 0.4 with the expectation that sRGB devices will clip slightly.

Consequently, testing OKLCH gradient output on both a P3 display and a standard sRGB monitor is important before deploying wide-gamut gradients. Building on this, the CapyToolkit gradient builder exports HEX values by default, which are sRGB-safe. To take advantage of OKLCH chroma beyond the sRGB gamut, write the gradient stops manually after copying the geometry. A practical workflow is to design the gradient geometry using the builder, then substitute the HEX stops with oklch() values tuned for the target display gamut, verifying the result in Safari on a P3 panel and Chrome on an sRGB monitor before shipping.

@supports fallback for in oklch interpolation

Browsers that lack in oklch support render the gradient with sRGB interpolation rather than producing an error. For gradients between complementary hues, this produces the grey midpoint artifact, but the gradient remains functional rather than broken. You do not need to detect oklch support to ship gradients that use in oklch; the worst case for unsupported browsers is a less vivid midpoint, not a missing gradient.

When you need to serve an alternative gradient to sRGB browsers, use @supports (color: oklch(0.7 0.2 250)) as the detection check2. Browsers supporting oklch() color syntax (Chrome 111+, Firefox 113+, Safari 16.4+) also support the in oklch interpolation modifier, so oklch() color support is a reliable proxy for interpolation support. Write the sRGB fallback gradient as the base rule and wrap the oklch-interpolated version inside the @supports block.

Progressive enhancement in Tailwind v4

The Tailwind v4 /oklch modifier applies the in oklch modifier automatically.5 Browsers without support ignore the modifier and render the gradient with the default sRGB interpolation, leaving the gradient intact. No additional @supports block is needed in Tailwind v4 projects: the modifier degrades gracefully by design, with no authoring overhead for the fallback case. This means you can ship OKLCH-enhanced gradients to all users today, with the vivid interpolation appearing automatically on modern browsers while older browsers still display a perfectly functional sRGB gradient.

When to use this

Use OKLCH interpolation for gradients between complementary or widely separated hues where sRGB produces a grey midpoint. Standard sRGB interpolation is the right call for monochromatic gradients and small hue-angle transitions, and one quick check tells you which case you have: test a blue-to-orange blend for a grey midpoint, then try two adjacent hues and watch the artifact disappear.

Examples

Blue-to-orange hero gradient without a grey midpoint

Write linear-gradient(in oklch, oklch(0.65 0.2 250), oklch(0.7 0.18 55)) in CSS, or use the Tailwind modifier bg-linear-to-r/oklch from-blue-500 to-orange-400 in Tailwind v4. The OKLCH path through hue 250 to 55 stays vivid throughout.

Full hue-sweep gradient for a color wheel or picker background

linear-gradient(in oklch, oklch(0.7 0.2 0), oklch(0.7 0.2 360)) travels through all hues at consistent lightness and chroma. The in oklch modifier ensures perceptually even spacing across the hue sweep compared to an hsl() gradient.

Gradient with a P3 wide-gamut midpoint stop

Add a center stop at oklch(0.75 0.38 180) to pull the midpoint toward a vivid green that exceeds sRGB. The browser clips to sRGB on standard monitors but renders the full P3 color on MacBook Pro M4, iPhone 17 Pro, or Samsung Galaxy S25 displays.

Sources
  1. 1.

    MDN Web Docs, "oklch() CSS function," developer.mozilla.org, accessed June 2026. https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color_value/oklch

  2. 2.

    MDN Web Docs, "<color-interpolation-method> CSS type," developer.mozilla.org, accessed June 2026. https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/color-interpolation-method

  3. 3.

    Andrey Sitnik, "OKLCH in CSS: why we moved from RGB and HSL," evilmartians.com, September 2025. https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl

  4. 4.

    W3C, "CSS Color Module Level 4," w3.org, September 2026. https://www.w3.org/TR/css-color-4/

  5. 5.

    Tailwind CSS, "Background Image," tailwindcss.com, accessed October 2026. https://tailwindcss.com/docs/background-image

FAQ

The in oklch modifier routes the color interpolation between stops through the OKLCH perceptual color space instead of the default sRGB. This produces vivid midpoints between widely separated hues rather than the dull grey midpoints that sRGB interpolation generates between complementary colors.

Chrome 111+, Edge 111+, Firefox 113+, and Safari 16.4+ all support the in oklch modifier for gradient interpolation. These versions cover the vast majority of current browser usage. Older browsers fall back to sRGB interpolation, which produces a grey midpoint but does not break the gradient. CapyToolkit's gradient builder exports HEX values by default, which are sRGB-safe; to take advantage of OKLCH chroma beyond the sRGB gamut, write the gradient stops manually after copying the geometry.

No. oklch() stop colors and the in oklch interpolation modifier are independent. You can write linear-gradient(oklch(0.7 0.2 250), oklch(0.7 0.2 30)) without in oklch, and the browser will interpolate those stops in sRGB (producing a grey midpoint). Add in oklch to route the blend through OKLCH perceptually.

The browser clips the out-of-gamut color to the nearest in-gamut sRGB value, typically by reducing chroma. The result looks slightly less saturated than the specified oklch() value on an sRGB display. On P3 displays (MacBook Pro, iPhone, many modern Android phones), the wider gamut renders the color as specified.

Yes. The interpolation modifier works with all CSS gradient functions: linear-gradient, radial-gradient, conic-gradient, repeating-linear-gradient, and repeating-conic-gradient. Write the modifier after the function keyword and before the first stop: repeating-conic-gradient(in oklch, oklch(0.7 0.2 0) 0deg, oklch(0.7 0.2 90deg) 90deg).

Additional resources

Guides

CSS Gradient Text with background-clip Apply a CSS gradient to text using background-image and background-clip: text. Browser support, fallback strategy, and live examples with the gradient builder. Animating CSS Gradients with @property Animate CSS gradient stops smoothly using @property custom properties. Browser support, fallback patterns, and OKLCH hue-rotation animations. CSS Mesh Gradient Technique Build mesh-style gradients in CSS using multiple layered radial-gradient() values on the same background-image. No SVG or canvas required. Tailwind CSS v4 Gradient Utilities Complete guide to Tailwind v4 gradient utilities. bg-linear-to-r, bg-radial, bg-conic, from-*, via-*, to-*, and in-oklch modifier reference. CSS Gradient Borders Apply CSS gradient borders using border-image or background-clip masking. Both techniques, browser support comparison, and border-radius workaround. OKLCH Interpolation in CSS Gradients Use OKLCH color space interpolation in CSS gradients with the in oklch modifier. How it eliminates grey midpoints and improves perceptual smoothness. CSS Gradients for Dark Mode UI Design CSS gradients for dark mode using reduced chroma, lower lightness stops, and prefers-color-scheme media queries. Practical patterns for UI surfaces. CSS Background Patterns with Gradients Build repeating CSS background patterns using gradient functions and background-size. Stripes, grids, dots, and diagonal tile techniques without images. Glassmorphism with CSS Gradients Implement the glassmorphism effect with CSS gradients, backdrop-filter blur, and translucent stops. Browser support and performance considerations. CSS Gradient Rendering Across Laptop and Phone Displays How CSS gradients render on the Dell XPS 16, iPhone 17 Pro, MacBook Air M4, MacBook Pro M4 and Galaxy S25: P3 color stops, OKLCH interpolation, OLED blacks and the browser engine each device runs.