Favorites

oklch() CSS Function

oklch()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The oklch() function defines a color by lightness, chroma and hue in the OKLCH color space, which keeps perceived lightness consistent across hues.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The oklch() CSS function defines a color in the OKLCH color space using lightness, chroma and hue. OKLCH is the cylindrical form of oklab(), a modern perceptual color space that improves on CIE Lab and lch(). Its biggest advantage is that changing the hue keeps colors looking equally light and equally saturated, and blues no longer drift toward purple, which makes it one of the best spaces for building design system palettes.

Lightness is a number from 0 (black) to 1 (white), or a percentage from 0% to 100%. Chroma is the amount of color, from 0 (gray) to about 0.4 for the most vivid colors; 100% equals 0.4. Hue is an angle in degrees. OKLCH can describe colors beyond sRGB, including wide-gamut P3 colors; if the screen cannot display a color, the browser maps it to the nearest displayable one. An optional alpha value can be added after a slash.

:root {
  --brand: oklch(62% 0.19 255);
}

.button {
  background-color: var(--brand);
}

/* Lighter and darker steps that keep the same hue */
.button:hover  { background-color: oklch(from var(--brand) calc(l + 0.08) c h); }
.button:active { background-color: oklch(from var(--brand) calc(l - 0.08) c h); }

/* A matching accent with the same lightness and chroma */
.accent {
  color: oklch(62% 0.19 145);
}

Because equal steps in OKLCH look equal to the eye, it is well suited for generating tints and shades, for accessible contrast work, and as an interpolation space for gradients, for example linear-gradient(in oklch, ...).

Interactive Demo

Colour swatch
Demo Code
HTML Code
<div class="demo-checker">
	<div class="demo-element">Colour swatch</div>
</div>
CSS Code
.demo-checker {
	width: 296px;
	padding: 18px;
	box-sizing: border-box;
	background: repeating-conic-gradient(#ddd 0 25%, #fff 0 50%) 0 0 / 20px 20px;
}
.demo-element {
	width: 260px;
	padding: 18px;
	border-radius: 8px;
	font-size: 16px;
	font-weight: bold;
	color: #fff;
	text-shadow: 0 1px 2px rgb(0 0 0 / 40%);
	background-color: oklch(0.65 0.24 355);
}

Syntax

oklch() = oklch( [ from <color> ]? [ <percentage> | <number> | none ]
[ <percentage> | <number> | none ]
[ <hue> | none ]
[ / [ <alpha-value> | none ] ]? )

Values

  • L (lightness)A <number> from 0 to 1 or a <percentage> from 0% to 100%. 0 is black and 1 (100%) is white.
  • C (chroma)A <number> or <percentage> for the amount of color. 0 is gray; 100% equals 0.4. Values are theoretically unbounded but rarely exceed 0.5.
  • H (hue)A <hue> (number of degrees or <angle>) giving the position on the color wheel.
  • alphaOptional. An <alpha-value> after a slash (/) from 0 to 1, or a percentage.

Example

<div class="wrap">
<h1>CSS oklch() examples</h1>
<div class="grid">
<div class="card">
<div class="sw s1"></div>
<div class="label">oklch(45% 0.19 255)</div>
</div>
<div class="card">
<div class="sw s2"></div>
<div class="label">oklch(62% 0.19 255)</div>
</div>
<div class="card">
<div class="sw s3"></div>
<div class="label">oklch(80% 0.12 255)</div>
</div>
<div class="card">
<div class="sw h1"></div>
<div class="label">oklch(70% 0.15 30)</div>
</div>
<div class="card">
<div class="sw h2"></div>
<div class="label">oklch(70% 0.15 145)</div>
</div>
<div class="card">
<div class="sw h3"></div>
<div class="label">oklch(70% 0.15 300)</div>
</div>
<div class="card">
<div class="sw rainbow"></div>
<div class="label">linear-gradient(in oklch longer hue, ...)</div>
</div>
</div>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* oklch() examples */
.sw {
height: 90px;
border-radius: 8px;
border: 1px solid rgba(16, 42, 67, 0.08);
}

.s1 { background: oklch(45% 0.19 255); }
.s2 { background: oklch(62% 0.19 255); }
.s3 { background: oklch(80% 0.12 255); }
.h1 { background: oklch(70% 0.15 30); }
.h2 { background: oklch(70% 0.15 145); }
.h3 { background: oklch(70% 0.15 300); }
.rainbow { background: linear-gradient(in oklch longer hue to right, oklch(70% 0.15 30), oklch(70% 0.15 30)); }
Open in editor

Browser Support

The following information will show you the current browser support for the CSS oklch() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.