Skip to content
All guides

Color reference

HEX, RGB, RGBA, HSL and OKLCH for design tokens

Follow one violet token from a Figma hex value to CSS. See how each format describes it, how to preserve opacity and when to use OKLCH for a palette.

Suppose your Figma button uses #5933A6, but its CSS token says rgb(89 51 166). Both describe the same violet. Each pair of hex digits is one channel in base 16. The pairs 59, 33 and A6 translate to 89, 51 and 166 in decimal.

Try the color converter

One violet in five CSS formats

Paste any value in the table into Source color. Each gives you the same six-digit hex output. The converter rounds the longer HSL and OKLCH coordinates for copying.

FormatCSS valueHow to read it
HEX#5933A6A compact value to paste into a Figma color field or a CSS token.
RGBrgb(89 51 166)The red, green and blue channels written as decimal numbers.
RGBArgba(89, 51, 166, 1)The same RGB channels in comma syntax, followed by opacity.
HSLhsl(259.826 52.9954% 42.549%)Hue, saturation and lightness. Useful when you want to adjust one of them by hand.
OKLCHoklch(43.6008% 0.173989 292.915)Perceptual lightness, chroma and hue. Useful when you build a scale of related colors.

Keep the opacity when you copy an overlay

For a violet overlay at half opacity, use rgb(89 51 166 / 50%). In older stylesheets you may see rgba(89, 51, 166, 0.5). CSS treats rgba() as an alias for rgb(). HSL and OKLCH also accept opacity after a slash.

The Source color field contains violet HSL with 50% opacity. The checkerboard shows through the preview.
Paste a value with alpha into Source color. The checkerboard makes transparency visible.

In eight-digit CSS hex, the last two digits encode opacity. The converter gives #5933A680 for this overlay. Its 80 is 128 out of 255, or about 50.2%. Keep the slash or decimal form when you need exactly 50%. Dropping the last two hex digits makes the violet fully opaque.

Use HSL to edit a hue and OKLCH to build a scale

HSL puts hue on a wheel. Try hsl(60 100% 50%) for yellow, then change 60 to 240 for blue. Both have 50% HSL lightness, yet the yellow looks much brighter. HSL is convenient for a quick hue edit. Its lightness number alone tells you little about how a row of swatches will look together.

For a violet scale, start with oklch(44% 0.17 293). Move the first value to 54% and then 64% while keeping chroma and hue fixed. This gives you three steps along a lightness axis designed around human perception. The hue angle belongs to the color space, so the same violet has different angles in HSL and OKLCH.

Some OKLCH colors extend beyond the range of sRGB. When the converter flags one, its HEX, RGB and HSL outputs use clipped channels. Preserve the OKLCH value as your source if that wider color range matters, and review the sRGB fallback separately.

Check the token where people will use it

Keep one source value for a token such as color/action/primary. Record the other formats when a tool or handoff needs them. For button text, test the actual foreground and background together in the contrast checker. An overlay needs a check on each surface where it appears.

For the channel definitions, alpha syntax and color spaces, see the CSS Color Module Level 4 specification.