liveBook · Manning

Color scale

As explained in Web Components in Action

A gradient is a visual transition in color or opacity across a spatial region.

A color scale uses gradients to turn a solid color into a spatial map of saturation and brightness. Start with a base color, then layer transparent-to-opaque gradients over it. section 11.2

Build the effect in small, familiar CSS steps:

  • Set the component background to the selected base color. section 11.2
  • Fade white from opaque on the left to transparent on the right to increase saturation across the horizontal axis. section 11.2
  • Fade transparent at the top to black at the bottom to vary brightness vertically. section 11.2

A red coordinate map

Give the component a red base with <wcia-coord-picker backgroundcolor="#ff0000"></wcia-coord-picker>. Two overlay elements provide the horizontal saturation fade and vertical brightness fade, while a draggable thumbnail marks the selected coordinates.

How Web Components in Action covers it

How deep it goes
Explains layered CSS gradients and pointer positioning, without descending into color-model theory.
Examples
Uses white and black overlay gradients above a red base in a draggable coordinate-picker demo.
What it assumes
Assumes familiarity with HTML, CSS backgrounds, DOM elements, and custom-element attributes.
What you can do after
Apply it via CSS linear-gradient and implement it in a draggable coordinate-picker component.
How it connects
Connects CSS gradients with opacity, Shadow DOM, Web Components, DOM attributes, and pointer events.

Also explained in

Compare how 5 books explain color scale →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Components in Action. The section links point to the parts of the book it draws on.