Mosmox UI
Current version
GitHubnpmjs.com
Forms & Inputs

Radio

Mutually exclusive selection controls for choosing one option

Radio represents one option in a mutually exclusive set. RadioGroup provides the shared name, selected value, direction, label, and controlled or uncontrolled group state.

Each radio supports default, sm, and xs visual sizes.

Basic group

import { Radio, RadioGroup } from '@mosmox/ui';

<RadioGroup label="Plan" name="plan" defaultValue="team">
  <Radio label="Personal" value="personal" />
  <Radio label="Team" value="team" />
  <Radio label="Enterprise" value="enterprise" />
</RadioGroup>

Only one radio in a group can be selected at a time. The group manages the native name and selection behavior.

Controlled group

const [plan, setPlan] = useState('team');

<RadioGroup
  label="Plan"
  name="plan"
  value={plan}
  onChange={(nextValue) => setPlan(nextValue)}
>
  <Radio label="Personal" value="personal" />
  <Radio label="Team" value="team" />
</RadioGroup>

Layout direction

The default direction is vertical. Use horizontal for compact option sets.

<RadioGroup label="Size" direction="horizontal" defaultValue="default">
  <Radio label="Default" value="default" size="default" />
  <Radio label="Small" value="small" size="sm" />
  <Radio label="Extra small" value="extra-small" size="xs" />
</RadioGroup>

Descriptions, errors, and disabled options

<RadioGroup label="Delivery" error="Choose a delivery method.">
  <Radio label="Standard" value="standard" description="Arrives in 3–5 days." />
  <Radio label="Express" value="express" disabled description="Not available for this address." />
</RadioGroup>

Both the group and an individual Radio can provide an error. Use a group error for selection validation and an individual error for an option-specific message.

Standalone radio

Radio can also be used directly when a native name is supplied manually:

<Radio name="contact" label="Email" value="email" defaultChecked />
<Radio name="contact" label="Phone" value="phone" />

Accessibility

  • RadioGroup renders a semantic fieldset and optional legend;
  • radios in a group share one native name and preserve keyboard selection behavior;
  • descriptions and errors are associated through aria-describedby;
  • disabled options remain visible but cannot be selected;
  • use a group label that describes the decision and option labels that are unambiguous.

Styling model

Radio colors, typography, focus, surface, and disabled treatment use shared theme tokens. Radio-specific circle geometry, selected dot, and group layout are in Radio.css.

API Reference

RadioGroup

PropertyTypeDefaultDescription
childrenReactNodeβ€”Radio options.
labelReactNodeβ€”Group legend.
namestringgeneratedShared native name for all options.
valuestringβ€”Controlled selected value.
defaultValuestringβ€”Initial uncontrolled selected value.
onChange(value, event) => voidβ€”Called with the selected value and native event.
direction`verticalhorizontal`vertical
errorstringβ€”Group validation message.

Radio

PropertyTypeDefaultDescription
labelReactNodeβ€”Visible option label.
descriptionstringβ€”Supporting option text.
errorstringβ€”Option-specific validation message.
sizedefault | sm | xsdefaultVisual size.
valuestringonNative option value.
checkedbooleanβ€”Controlled standalone checked state.
defaultCheckedbooleanfalseInitial standalone checked state.
onChangeChangeEventHandler<HTMLInputElement>β€”Native radio change handler.
disabledbooleanfalseDisables the option.
requiredbooleanfalseEnables native required validation.
namestringgroup nameStandalone native group name.

Other supported native radio input attributes are forwarded to the underlying <input>.