liveBook · Manning

Color picker

As explained in CSS in Depth, Second Edition

A color picker is an interactive tool for selecting, inspecting, and converting colors through controls such as swatches, sliders, and text inputs.

A color picker helps you inspect a page’s existing colors, convert their notation, and adjust a palette while seeing the result. Browser DevTools is a convenient starting point because the applied colors are already beside the styles you are editing. section 11.3

Start with a color already on the page:

  • Open DevTools, select the html element in the Elements panel, and find its color custom properties in Styles. The small square beside each value previews that color. section 11.3
  • Shift-click the square to change notation: Chrome offers a dropdown, while Firefox and Safari cycle through notations. Click the square to open the picker for fine-tuning, palette selection, or sampling a page color with the eyedropper. section 11.3
  • Edit a color live and check it in context. If the color belongs to an active style, force that state in DevTools so the element remains visible while you adjust it. section 11.3.4

For more control over OKLCH, oklch.com provides a swatch, lightness, chroma, hue, and alpha sliders, and a text box that converts pasted color syntax to OKLCH. Its color areas leave undisplayable colors blank, helping you choose within a desired gamut. In a wide-gamut DevTools picker, a white line marks the sRGB limit; a color beyond it may appear only approximately on an sRGB monitor. section 11.3.4 section 11.3

Add a palette color

A palette can include `--red: oklch(64% 0.15 10deg);` alongside existing green, gray, and white custom properties. Adjust its lightness and chroma in a picker, then inspect the rendered result rather than relying on the numeric value alone. section 11.3.4

Figure 11.16 The oklch.com color picker
figure

The oklch.com picker shows the swatch and controls used to adjust an OKLCH color. section 11.3.4

How CSS in Depth, Second Edition covers it

How deep it goes
Walks through DevTools controls and an OKLCH picker, including gamut boundaries; it does not develop color theory.
Examples
Uses applied colors in DevTools, an OKLCH red palette value, and the oklch.com picker.
What it assumes
Assumes familiarity with CSS styles and custom properties, while showing where to find the relevant DevTools controls.
What you can do after
Apply it via DevTools or oklch.com to convert, fine-tune, and preview colors within a desired gamut.
How it connects
Connects color picking to CSS custom properties, OKLCH, color notation, pseudo-class states, and color gamut.

Also explained in

Compare how 4 books explain color picker →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.