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.
Design examples
Section titled “Design examples”Named swatches, exact values and the native picker share a row. Sample colours come from the shared palette.
<section class="specimen">
<ds-row class="line" ><ds-swatch value="#99ff73" aria-hidden="true"></ds-swatch><ds-text literal class="grow">Apple green</ds-text><ds-color><input type="color" value="#99ff73" aria-label="Apple green"></ds-color></ds-row><ds-row class="line" ><ds-swatch value="#ccccff" aria-hidden="true"></ds-swatch><ds-text literal class="grow">Zenith blue</ds-text><ds-color><input type="color" value="#ccccff" aria-label="Zenith blue"></ds-color></ds-row><ds-row class="line" ><ds-swatch value="#f5aad1" aria-hidden="true"></ds-swatch><ds-text literal class="grow">Pink</ds-text><ds-color><input type="color" value="#f5aad1" aria-label="Pink"></ds-color></ds-row>
</section>
<style>
.specimen { width: 100%; min-width: 0; --cell: calc(20px * var(--sf, 1)); }
.specimen .line { width: 100%; }
.specimen .grow { flex: 1; min-width: 0; }
.specimen .muted { color: var(--ds-text-color-muted); }
.specimen .mono { --ds-typeface-regular: var(--ds-typeface-mono); font-variant-numeric: tabular-nums; }
.specimen .value { width: calc(4 * var(--cell)); text-align: right; }
.specimen .mark { display: inline-flex; align-items: flex-end; width: var(--cell); height: var(--ds-control-height); flex: 0 0 var(--cell); }
.specimen .columns { display: flex; flex-wrap: wrap; gap: var(--cell); }
.specimen .columns > * { min-width: 0; }
.specimen fieldset { border: 0; padding: 0; margin: 0; }
.specimen legend { padding: 0; }
.specimen label { display: flex; align-items: flex-end; gap: calc(var(--cell) / 2); min-height: var(--cell); }
.specimen ds-panel { height: calc(10 * var(--cell)); }
</style> Behaviour
Section titled “Behaviour”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.
Accessibility
Section titled “Accessibility”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.
| Slot | What it holds |
|---|---|
| Default | One input type="color". |
It has no events or tokens of its own. Copy color through Sync 1.
Contrast
Section titled “Contrast”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>`.