Color

ds-color draws a native colour field two squares wide and one square high. The native input owns its platform picker, accessible label, form value, disabled fieldsets and reset. DS1 owns its border, focus, padding and scale.

<label>Exact colour  <ds-color><input type="color" name="accent" value="#99ff73" /></ds-color></label>

Native input props and refs belong to the input. Put layout classes and width on the host. Register the component before hydrating in the browser.

ds-swatch displays a colour sample inside a shared button or beside a label. It is four fifths of a square, scaled with the surface, fitting within a one-square row. Its value is a CSS colour; selected adds a visible selection outline. It is decorative: give its enclosing button an accessible name and pressed state, or supply adjacent text. Colour data and saving belong to the product.

<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>

For an exact hex text entry, compose with ds-input. The product validates its stored colour format and any contrast or permission requirements. Keep those requirements separate from the native picker and shared visual controls.

A print palette

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

The field is two squares wide and one high, and it fills that box with the input. The colour stands 2px inside a 1px line with the field’s corners. A press opens the browser’s own picker, and the value and its change events are the input’s. disabled and a disabled fieldset dim the field to half and leave it unpressable.

ds-color also works inside a shadow root: it adds its stylesheet to that root once.

The native input is what assistive technology meets, so it needs a name: a label around it, or aria-label on it. Focus shows as a 2px ring. Calling focus() on ds-color moves focus to the input. Never let a colour alone carry a choice: name it in words too.

ds-color has no attributes of its own. Set name, value, disabled and the rest on the input.

SlotWhat it holds
DefaultOne input type="color".

It has no events or tokens of its own. Copy color through Sync 1.

color.text-contrast
Visible text, including muted labels, placeholders and avatar initials, has at least 4.5:1 contrast against the background it is drawn on. Measure resolved colours through slots and open shadow roots, including transparency and opacity; image backgrounds and effects that cannot be measured need a visual review. In products, contrast-watch.ts measures the theme in use after load and reports each failure as `contrast.<theme>.<component>`.