UI

Radio

Mutually exclusive option cards with a gliding selection ring.

import { Radio } from '@uthereal/ui/radio'

Radio playground

Plan
Loading interactive preview…

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.

LayoutArrangementCard chromemeta placementBest for
gridResponsive columns (minColumnWidth, default 180px)Bordered card + gliding ringBelow description, aligned baselineSide-by-side plans or tiers
listFull-width stacked cardsBordered card + gliding ringInline end of the rowShipping speeds, payment methods
compactMinimal stacked rowsBorderless, no ringHiddenShort form settings without prices
Delivery speed
Default visibility

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.

Compute tier
Billing region
Choose a billing region before continuing.

API reference

These serializable arguments and defaults come directly from the component schema.

ArgumentType / defaultDescription
labelstringDefault: "Plan"Visible group label and accessible name of the radiogroup. Name the decision in sentence case, e.g. "Plan".
hideLabelbooleanDefault: falseHide the label visually when the context already names the field. It is still announced.
descriptionstring—Supporting text below the options, announced with the group. Use it for consequences or constraints.
errorstring—Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely.
requiredbooleanDefault: falseMarks the group as required for assistive technology and shows an indicator. Your application validates that an option is chosen.
disabledbooleanDefault: falseThe whole group is unavailable and leaves the tab order. Disable single options with options[].disabled.
namestring—Native form field name, submitted with the value in a form.
optionsRadioOption[]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.
defaultValuestring | nullDefault: nullValue 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.
layoutgrid | 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.
minColumnWidthintegerDefault: 180Narrowest a grid column may get before the grid drops a column, px. Only the grid layout uses it.
sizesm | md | lgDefault: "md"Indicator and text size; cards draw an 18px indicator with a 6px dot.
recipestudio | softDefault: "studio"Visual treatment. Both recipes use the same interaction behavior.
themeRadioTheme—Color mode, accent, and tokens, including controlOn, controlGlyph, controlFill, and surfaceRaised. See Theming.
motionnone | 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.
motionOptionsRadioMotionOptionsDefault: {}Fine-grained overrides: ring (the glide between cards), fade (the first appearance), and dot (the indicator dot).
dirltr | rtl—Reading direction; cards sit at the inline start. Omit it to inherit the page direction.

Option fields (RadioOption)

FieldTypePurpose
valuestringUnique stable identifier reported to onValueChange and forms.
labelstringPrimary visible option text.
descriptionstringOptional supporting copy below the label.
metastringShort value such as a price or estimate (grid and list layouts).
iconIconNameOptional decorative icon before the label.
disabledbooleanMarks this option unavailable and skips it during arrow navigation.
disabledReasonstringReplaces description while the option is disabled.

React integration

PropPurpose
value, onValueChangeControl 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.
refRef to the role="radiogroup" element.
idRadiogroup id; label, description, error, and option ids derive from it.
presetApplication defaults, overridden by explicit instance props.
tokensCSS variables applied after the typed theme.
className, styleApplied to the outer field root, which carries the resolved --ui-* tokens.
Native attributesaria-*, data-*, and event handlers forwarded to the radiogroup element.

Keyboard & accessibility

KeyInteraction
TabMove focus into or out of the group as a single tab stop.
ArrowRight, ArrowDownMove to and select the next enabled option, wrapping. Flipped in RTL.
ArrowLeft, ArrowUpMove to and select the previous enabled option, wrapping. Flipped in RTL.
Home, EndMove to and select the first or last enabled option.
Space, EnterSelect 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": []
}

On this page