Skip to content
IndexRequest a UIAboutContact

Radio Button

A single-choice group with a growing dot and arrow-key navigation.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Build a radio group "Delivery speed" with three option cards (Standard — free, Express — $9, Same day — $19), each a label wrapping a real input type="radio" name="speed" (visually hidden), a 22px ring with an inner dot, a title and a one-line description. Selecting a card highlights its border with the accent colour and scales the dot from 0 to 1 over 180ms with cubic-bezier(0.3,1.6,0.5,1). Standard is preselected. Keep native arrow-key behaviour and one tab stop for the group, wrap the group in a fieldset with a legend, show a 2px focus-visible ring on the card, and include a disabled option at 40% opacity. Print the selected value below the group. Disable the overshoot under prefers-reduced-motion.

About this pattern

Definition

A group of options where exactly one can be selected. Selecting one automatically deselects the others. The selected option shows a dot that grows inside a ring.

Purpose & UX principles

  • Use radio buttons when the choices are mutually exclusive and the list is short enough to scan at once (about 2 to 6 options).
  • For longer lists use a dropdown instead.
  • Always preselect the safest or most common option unless a deliberate choice is needed.

Interaction states

  • Unselected, selected, hover, focus-visible, disabled.
  • Native radios give arrow-key movement inside a group and a single tab stop for free; do not replace them with divs.

Motion specification

  • Dot: scale from 0 to 1 in 180ms with a slight overshoot.
  • Card border colour: 160ms.
  • Reduced motion: dot appears instantly.

Responsive behaviour

  • Stack the options vertically; each row is at least 44px tall and fully clickable.
  • Option "cards" with a description work well on phones.

Code

HTML
<fieldset class="rg"><legend>Delivery speed</legend>
  <label class="o"><input type="radio" name="s" value="standard" checked><i></i><span><b>Standard</b><small>3–5 days · Free</small></span></label>
  <label class="o"><input type="radio" name="s" value="express"><i></i><span><b>Express</b><small>1–2 days · $9</small></span></label>
  <label class="o"><input type="radio" name="s" value="same-day"><i></i><span><b>Same day</b><small>Today · $19</small></span></label>
  <label class="o dis"><input type="radio" name="s" value="drone" disabled><i></i><span><b>Drone</b><small>Not in your area</small></span></label>
</fieldset>
<p class="out">Selected: <b id="v">standard</b></p>

Related patterns

Checkbox

↗
CheckboxInputs & Forms

Toggle Switch

↗
Toggle SwitchInputs & Forms

Tab Navigation

↗
Tab NavigationNavigation