Skip to content

Radio Group

Coordinate a roving native radio group. Custom element

Radio Group
Copy this markup
<ui-radio-group value="system" aria-labelledby="theme-label">
<span id="theme-label">Theme</span>
<label>
<input type="radio" name="theme" value="system" checked>
System
</label>
<label>
<input type="radio" name="theme" value="light">
Light
</label>
<label>
<input type="radio" name="theme" value="dark">
Dark
</label>
</ui-radio-group>

Install

Styles and registration
import '@timelessui/components/css/tokens.css'
import '@timelessui/components/css/choice-group.css'
import '@timelessui/components/define/ui-radio-group'

Anatomy

Parts are authored in your own markup and identified by the selector below, so your CSS can target the same anatomy without loading Timeless styles. Required parts must be present for the component to work. Private data-ui-internal-* hooks are written by the runtime and must never be authored.

PartRequiredSelectorPurpose
choiceYesinput[type='radio']One native radio input, sharing a name with the rest. Native form submission and reset keep working.

Attributes

Every value below is implemented by the stylesheets this component ships. Boolean attributes are presence-based: author the attribute with no value, or omit it.

AttributeValuesDefaultDescription
orientationvertical · horizontalverticalLayout and arrow-key axis.
valueany stringThe radio checked on load and after a form reset. Match one input’s value. Assign the value property for live changes.

Element API

Attributes above are the authoring surface. These are the DOM properties and events the registered element adds once it upgrades.

<ui-radio-group>

PropertyTypeNotes
orientation'vertical' | 'horizontal'Reflects the orientation attribute, documented above.
defaultValuestringReflects the value attribute, documented above.
valuestringLive value. Assigning it does not rewrite the authored default and does not dispatch transition events.
EventDetailDescription
ui-before-changeCustomEvent<RadioGroupChangeDetail>Cancelable proposal dispatched before the checked radio changes. Call preventDefault() to reject the transition and keep the current value.
ui-changeCustomEvent<RadioGroupChangeDetail>Dispatched after the checked radio has changed. Bubbles and is composed.

Styling

Root identity: ui-radio-group. Required stylesheets: tokens.css, choice-group.css.

This component adds no custom properties of its own. Restyle it through the design tokens or your own CSS.

Design tokens this component reads (7)

These are global Atmosphere tokens. Change them once at the theme level rather than per component.

--ui-accent · --ui-disabled-opacity · --ui-fg · --ui-fg-muted · --ui-focus · --ui-space-2 · --ui-space-3

Accessibility

Keep the native elements, roles, and relationships shown in the example. Timeless adds only the state and keyboard coordination the platform does not already provide, and it never supplies your accessible names — those depend on your content.

Follows the Radio Group pattern from the ARIA Authoring Practices Guide.

KeyAction
Arrow keysMove focus to the previous or next radio, following the orientation and skipping disabled ones.
Home / EndMove focus to the first or last enabled radio.
Page Up / Page DownJump ten radios at a time.

Native radio semantics do the rest: one tab stop per group, checked state, form submission, and reset. Timeless adds roving focus and change events without replacing the inputs.

Before JavaScript runs

The markup above is complete and usable on its own: native controls submit, labels associate, and authored ARIA is already correct. Registration adds state synchronisation, focus management, and keyboard coordination on top of it.

More examples

Open Radio Group in StoryLite for variants, controls, and manual testing.