Radio
ds-radio wraps a native input type="radio". The browser owns grouping,
Arrow and Space keys, labels, required validation, form values, reset and
disabled fieldsets. Radios in one group share a name; separate groups need
distinct names. DS1 owns the face, focus ring, disabled state and scale.
<fieldset><legend>Access</legend> <label><ds-radio><input type="radio" name="access" value="all" checked></ds-radio>All projects</label> <label><ds-radio><input type="radio" name="access" value="selected"></ds-radio>Selected projects</label></fieldset>The standard control is one square in each direction. choice presents the
same native radio as a labelled choice, four squares wide and one high.
compact makes it one square wide. preview adds a two-row preview above the
label; put product artwork in the preview slot. Always give the native input
an accessible name; the decorative face is hidden from assistive technology.
<ds-radio choice preview label="Grid"> <input type="radio" name="pattern" value="grid" aria-label="Grid"> <span slot="preview">Product artwork</span></ds-radio>React products import Radio from DS1/react/choice. Standard native props
and the native input ref pass through. label supplies the visible choice
label and the native accessible name unless aria-label is supplied.
preview accepts decorative React content. The adapter renders on the server;
register ds-radio in the browser before hydrating. Use React useId() for
independent groups that can mount more than once.
<Radio choice name={groupName} value="grid" label="Grid" checked={pattern === "grid"} onChange={() => setPattern("grid")} preview={<PatternPreview pattern="grid" />} />Products keep choice data, preview artwork, selection decisions and persistence. Remove replaced selection, focus and control face CSS. Do not recreate radio keyboard logic or move native inputs into separate shadow roots. Check accepted and declined controlled edits, required forms, reset, labels, multiple groups, disabled fieldsets, narrow layouts and independent surface scales.
Design examples
Section titled “Design examples”A single selection, arranged on one-square rows.
<section class="specimen">
<fieldset><legend>Edition</legend><label><ds-radio><input type="radio" name="edition" value="0" checked></ds-radio>Softcover</label><label><ds-radio><input type="radio" name="edition" value="1" ></ds-radio>Clothbound</label><label><ds-radio><input type="radio" name="edition" value="2" ></ds-radio>Signed copy</label></fieldset>
</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: 0; min-height: var(--cell); }
.specimen ds-panel { height: calc(10 * var(--cell)); }
</style> Try it
Section titled “Try it”A native radio group under labelled faces. The arrow keys move the choice.
<ds-radio choice preview label="Green"><input type="radio" name="ink" value="green" aria-label="Green" checked><ds-swatch slot="preview" value="#99ff73" aria-hidden="true"></ds-swatch></ds-radio>
<ds-radio choice preview label="Blue"><input type="radio" name="ink" value="blue" aria-label="Blue"><ds-swatch slot="preview" value="#ccccff" aria-hidden="true"></ds-swatch></ds-radio>
<ds-radio choice preview label="Pink"><input type="radio" name="ink" value="pink" aria-label="Pink"><ds-swatch slot="preview" value="#f5aad1" aria-hidden="true"></ds-swatch></ds-radio> Accessibility
Section titled “Accessibility”The native input does everything assistive technology meets: its name, its group, its checked state and its keys. Focus shows as a 2px ring. Calling focus() on ds-radio moves focus to the input. A label on a choice is drawn in a face hidden from assistive technology, so name the input too, with aria-label or a label. Words that do not fit fade over their last square.
| Attribute | Type | Default | What it does |
|---|---|---|---|
choice | boolean | false | A labelled choice four squares wide and one high. |
compact | boolean | false | With choice, one square wide. |
preview | boolean | false | With choice, adds the preview and stands three squares high. |
label | string | Empty | The words on a choice. |
| Slot | What it holds |
|---|---|
| Default | One native input type="radio". |
preview | The artwork above the label. |
It has no events or tokens of its own: listen to the input’s change, and set name, value, checked, required and disabled on the input. Add hidden to hide it. Copy radio through Sync 1. On Apple platforms and Android it is DS1Radio, or DS1Choice for a labelled choice.