Swatch

A swatch shows one colour in a square of its own, four fifths of a square wide and high (16px), so it stands on the sixteen beside words. A 1px line runs round the colour, so a pale colour still shows on the paper. It has square corners, and it draws nothing else.

A print palette

Named swatches, exact values and the native picker share a row. Sample colours come from the shared palette.

Colour choices

Each sample stands in an icon button with its own name. The selected one carries the outline.

<ds-button control="slotted" icon>  <button type="button" aria-label="Apple green" aria-pressed="true">    <ds-swatch value="#99ff73" selected aria-hidden="true"></ds-swatch>  </button></ds-button>

value takes any CSS colour, a token included. It sets only the swatch’s background, so a value that is not a colour draws nothing and cannot add other styles. With no value it is transparent, and only the line shows.

selected draws a 2px outline in the text’s ink around the swatch. The swatch does not change it by itself: the page sets and clears it.

A swatch has no press of its own. For a choice, put it in a shared button. Select draws one in its control when given swatch. Colour data, saving and any contrast or permission rules belong to the product.

A swatch has no role and no name, and a colour alone says nothing to someone who cannot see it. Mark it aria-hidden="true", then name the colour on the button around it or in the words beside it. Show a choice with aria-pressed on the button: the outline is only drawn.

AttributeTypeDefaultWhat it does
valuestringtransparentThe CSS colour shown.
selectedbooleanfalseDraws the selection outline.

It has no slots, events or tokens of its own. The line is --ds-border-color and the outline --ds-text-color. Add hidden to hide it.

Copy swatch through Sync 1. There is no React adapter: render ds-swatch itself after registering ds1/2-core/ds-swatch. On Apple platforms it is DS1Swatch.

Color · Select · Colours