Radio
Mutually exclusive option cards with a gliding selection ring.
import { Radio } from '@uthereal/ui/radio'Radio playground
Overview
A labelled group of mutually exclusive options inside the field anatomy. In grid and list layouts, options render as bordered cards with one selection ring that glides between choices. Each option supports a label, description, decorative icon, short meta value, and a disabledReason when unavailable.
Use Radio when users need to compare every option at once, such as billing plans, shipping speeds, or deployment regions. Use MorphSelect or Multiselect for long or searchable lists. Use Checkbox for independent choices, Switch for settings that apply immediately, and Tabs for switching views in place.
Usage
'use client'
import { useState } from 'react'
import { Radio } from '@uthereal/ui/radio'
export function PlanSelector() {
const [plan, setPlan] = useState<string | null>('team')
return (
<Radio
label="Plan"
value={plan}
onValueChange={setPlan}
options={[
{ value: 'solo', label: 'Solo', description: 'One seat', meta: '$12' },
{
value: 'team',
label: 'Team',
description: 'Up to 20 seats',
meta: '$49',
},
]}
/>
)
}Pass value and onValueChange to control the chosen option. Omit value to let the component manage its own state starting from defaultValue (null selects none and hides the ring until the user picks an option). onValueChange fires in both modes.
Examples
Layouts
Choose a layout based on how much detail each option carries.
| Layout | Arrangement | Card chrome | meta placement | Best for |
|---|---|---|---|---|
grid | Responsive columns (minColumnWidth, default 180px) | Bordered card + gliding ring | Below description, aligned baseline | Side-by-side plans or tiers |
list | Full-width stacked cards | Bordered card + gliding ring | Inline end of the row | Shipping speeds, payment methods |
compact | Minimal stacked rows | Borderless, no ring | Hidden | Short form settings without prices |
States
Disable individual options with disabled: true and explain why with disabledReason, which replaces the option description while unavailable. Start with defaultValue: null when no default applies, and set error to mark the group invalid and announce validation guidance.
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Plan" | Visible group label and accessible name of the radiogroup. Name the decision in sentence case, e.g. "Plan". |
hideLabel | booleanDefault: false | Hide the label visually when the context already names the field. It is still announced. |
description | string— | Supporting text below the options, announced with the group. Use it for consequences or constraints. |
error | string— | Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely. |
required | booleanDefault: false | Marks the group as required for assistive technology and shows an indicator. Your application validates that an option is chosen. |
disabled | booleanDefault: false | The whole group is unavailable and leaves the tab order. Disable single options with options[].disabled. |
name | string— | Native form field name, submitted with the value in a form. |
options | RadioOption[]Default: [{"value":"solo","label":"Solo","description":"One seat","disabled":false},{"value":"team","label":"Team","description":"Up to 20 seats","disabled":false}] | The choices, in order: value (unique, reported when chosen), label, optional description, meta (a price or estimate), icon, disabled, and disabledReason (shown instead of the description while the option is unavailable). Up to 24; use a select for longer lists. |
defaultValue | string | nullDefault: null | Value of the initially chosen option. Set null to start with none chosen. Later argument edits do not reset an existing instance; use value and onValueChange to control it. |
layout | grid | list | compactDefault: "grid" | grid (default, Arc radio cards) fills responsive columns no narrower than minColumnWidth; list stacks full-width cards with the meta at the inline end; compact draws minimal borderless rows for simple forms. |
minColumnWidth | integerDefault: 180 | Narrowest a grid column may get before the grid drops a column, px. Only the grid layout uses it. |
size | sm | md | lgDefault: "md" | Indicator and text size; cards draw an 18px indicator with a 6px dot. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes use the same interaction behavior. |
theme | RadioTheme— | Color mode, accent, and tokens, including controlOn, controlGlyph, controlFill, and surfaceRaised. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | The ring glide, the dot spring, and color transitions; motionOptions fine-tunes the ring, its first fade-in, and the dot. none and system reduced-motion preferences make them immediate. |
motionOptions | RadioMotionOptionsDefault: {} | Fine-grained overrides: ring (the glide between cards), fade (the first appearance), and dot (the indicator dot). |
dir | ltr | rtl— | Reading direction; cards sit at the inline start. Omit it to inherit the page direction. |
Option fields (RadioOption)
| Field | Type | Purpose |
|---|---|---|
value | string | Unique stable identifier reported to onValueChange and forms. |
label | string | Primary visible option text. |
description | string | Optional supporting copy below the label. |
meta | string | Short value such as a price or estimate (grid and list layouts). |
icon | IconName | Optional decorative icon before the label. |
disabled | boolean | Marks this option unavailable and skips it during arrow navigation. |
disabledReason | string | Replaces description while the option is disabled. |
React integration
| Prop | Purpose |
|---|---|
value, onValueChange | Control the chosen option value (null selects none). Callback fires in both modes. |
renderIcon(name, context) | Render a custom decorative icon; context provides size (18), slot, and value. |
ref | Ref to the role="radiogroup" element. |
id | Radiogroup id; label, description, error, and option ids derive from it. |
preset | Application defaults, overridden by explicit instance props. |
tokens | CSS variables applied after the typed theme. |
className, style | Applied to the outer field root, which carries the resolved --ui-* tokens. |
| Native attributes | aria-*, data-*, and event handlers forwarded to the radiogroup element. |
Keyboard & accessibility
| Key | Interaction |
|---|---|
Tab | Move focus into or out of the group as a single tab stop. |
ArrowRight, ArrowDown | Move to and select the next enabled option, wrapping. Flipped in RTL. |
ArrowLeft, ArrowUp | Move to and select the previous enabled option, wrapping. Flipped in RTL. |
Home, End | Move to and select the first or last enabled option. |
Space, Enter | Select the focused option when none is checked yet. |
Each option wraps a visually hidden native <input type="radio"> inside a <label>, so forms submit the chosen value under name without custom form plumbing. The group exposes role="radiogroup" named by aria-labelledby, with group description and error linked through aria-describedby. Each option input links its description (or disabledReason when disabled) and visible meta through aria-describedby. Errors set aria-invalid and render in a role="alert" region. required sets aria-required so your application owns validation messages without native browser bubbles.
In RTL (dir="rtl"), CSS logical properties and grid areas mirror the cards, ArrowLeft and ArrowRight invert, and the selection ring measures travel from the inline-start edge. Under forced-colors: active, the gliding ring hides, checked card borders and indicators use Highlight, the indicator dot uses HighlightText, and disabled options use GrayText.
Motion and theming
In grid and list layouts, one ring glides to the newly chosen card on a spring (visualSpring(0.42, 0.14)). On its first appearance, the ring fades in over 160 ms on the standard curve without travelling from the origin. When the group or a card resizes, ResizeObserver snaps the ring immediately without replaying the glide. The indicator dot scales from 0 to 1 on the snappy spring, and card borders and fills crossfade over 160 ms. Override individual animations with motionOptions.ring, motionOptions.fade, and motionOptions.dot. Setting motion="none" or enabling prefers-reduced-motion: reduce makes every ring move, fade, dot scale, and CSS color transition immediate (0 ms).
theme accepts mode, accent, and token overrides from the field core and control scales (borderStrong, surfaceRaised, textSecondary, highlight, danger, focusRing, disabledOpacity, and controlGap) plus selection control tokens (controlOn, controlGlyph, and controlFill). Supply application-wide defaults with UtherealProvider.
Composition
Radio is a leaf component in agent compositions. Its chosen value is stored as host state at /fields/instance-<id>/value, initialized from defaultValue. If a later edit removes the chosen option, host reconciliation falls back to defaultValue or null. See Building with agents.
{
"type": "Radio",
"props": {
"label": "Delivery speed",
"layout": "list",
"defaultValue": "standard",
"options": [
{
"value": "standard",
"label": "Standard",
"description": "3 to 5 business days",
"meta": "Free"
},
{
"value": "express",
"label": "Express",
"description": "Next business day",
"meta": "$14"
}
]
},
"children": []
}