Selection

Swatch picker

Colour choices as radio squares; the chosen one gets a two-ring halo.

Examples

Swatch picker

Anatomy

.swatch-groupA wrapping row of swatches.
> labelOne square per colour, filled with its --swatch.
label > input[type=radio]Covers the square, invisible. All share a name.
label > span.sr-onlyThe colour's name, as the radio's accessible name.

API

AttributeValuesDescription
--swatch<colour>On each label: the colour of its square.
checkedbooleanOn one radio: draws a background-coloured gap and a text-coloured ring around its square.

Accessibility

  • Every swatch needs its colour named in span.sr-only; the square alone says nothing to a screen reader.
  • Name the group: wrap it in a <fieldset> with a <legend>, or add role="radiogroup" and an aria-label.
  • Selection is shown by the rings, not by colour, so it reads on any swatch.
KeyEffect
← / →Moves the selection to the previous or next colour.
Jump to
ProportionFoundations
MaterialFoundations
PresetsFoundations
ShellLayouts · Application
Container and stacksLayouts · Pages
SplitLayouts · Pages
Grid, bento, masonryLayouts · Pages
Switcher and rowLayouts · Pages
↑↓Move↵OpenescClose