Internal ID software / Forms
RadioGroup
One question with a few answers, all shown.
Not drawn in Figma: built only from the tokens, for internal ID software. In code: components/software/form.tsx. From the old system: RadioGroup in @id-identity-as/ui/form.
Example
import { RadioGroup } from '@/components/software/form';
<RadioGroup
label="Levering"
name="delivery"
required
defaultValue="standard"
options={[{ value: 'standard', label: 'Standard, 2 til 4 dage' }, { value: 'express', label: 'Ekspres, næste hverdag' }]}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
label (required) | string | The question. It is the legend of the group. | |
name (required) | string | The form field name. One group is one question. | |
options (required) | SelectOption[] | { value, label, disabled? }. | |
value | string | The chosen value. With onChange the group is controlled. | |
defaultValue | string | The value chosen from the start, uncontrolled. | |
onChange | (value: string) => void | Called with the new value. | |
helper | string | Guidance under the group. | |
error | string | What to do about a problem. | |
required | boolean | Required groups carry no mark. The optional ones are marked. | |
optionalLabel | string | '(valgfrit)' | The mark on an optional group. |
Do
- Use it for up to about five answers. More than that is a Select.
- Choose a default only when one answer is right for most.
Do not
- Do not use it for a product colour or size. That is VariationPicker.
- Do not lay radio buttons out without their fieldset and legend.
Accessibility
- One fieldset with one legend, so a screen reader says what the options are for.
- Native radio buttons: arrow keys move, a form posts the value.
Tokens it uses
- color.text.default
- color.software.muted
- type.body.md
- type.body.sm
- type.heading.sm
- space.inline.2
- space.inline.3
- space.inline.5