Skip to content

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

Levering

Gælder hele ordren.

Levering

Gælder hele ordren.

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

PropTypeDefaultWhat it does
label (required)stringThe question. It is the legend of the group.
name (required)stringThe form field name. One group is one question.
options (required)SelectOption[]{ value, label, disabled? }.
valuestringThe chosen value. With onChange the group is controlled.
defaultValuestringThe value chosen from the start, uncontrolled.
onChange(value: string) => voidCalled with the new value.
helperstringGuidance under the group.
errorstringWhat to do about a problem.
requiredbooleanRequired groups carry no mark. The optional ones are marked.
optionalLabelstring'(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