Skip to content

Radio

Radio buttons let the user select one option from a visible list. Uses native <input type="radio"> with custom visual indicators.


Preview

Sagen handler om

Usage

html
<fieldset class="choice-group">
  <legend class="choice-group__legend">Sagen handler om</legend>
  <p class="choice-group__hint">Vælg den kategori der passer bedst</p>

  <div class="choice-group__list" role="radiogroup">
    <label class="choice choice--radio" for="r1">
      <input id="r1" class="choice__input" type="radio" name="subject" value="insurance" />
      <span class="choice__indicator" aria-hidden="true"></span>
      <span class="choice__body">
        <span class="choice__label">Ulykkesforsikring</span>
      </span>
    </label>
    <label class="choice choice--radio" for="r2">
      <input id="r2" class="choice__input" type="radio" name="subject" value="liability" />
      <span class="choice__indicator" aria-hidden="true"></span>
      <span class="choice__body">
        <span class="choice__label">Erstatningsansvar</span>
      </span>
    </label>
  </div>
</fieldset>

Classes

ClassDescription
.choice-groupFieldset wrapper
.choice-group__legendGroup label
.choice-group__hintGroup help text
.choice-group__errorGroup error message
.choice-group__listVertical list container
.choiceSingle option wrapper
.choice--radioRadio variant (circle indicator)
.choice--checkedSelected state
.choice--errorError state
.choice--disabledDisabled state
.choice__inputHidden native input
.choice__indicatorCustom visual circle/square
.choice__bodyLabel + hint container
.choice__labelOption label text
.choice__hintOption help text
.choice__contentCollapsible content (shown when checked)

Accessibility

  • Native <input type="radio"> provides keyboard navigation (arrow keys)
  • <fieldset> + <legend> for group labeling
  • role="radiogroup" on the list
  • Focus visible on indicator via :focus-visible on input
  • Label click selects option (native <label for>)

References