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
RadioGrouprenders a semanticfieldsetand optionallegend;- radios in a group share one native
nameand 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
| Property | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Radio options. |
label | ReactNode | — | Group legend. |
name | string | generated | Shared native name for all options. |
value | string | — | Controlled selected value. |
defaultValue | string | — | Initial uncontrolled selected value. |
onChange | (value, event) => void | — | Called with the selected value and native event. |
direction | `vertical | horizontal` | vertical |
error | string | — | Group validation message. |
Radio
| Property | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | Visible option label. |
description | string | — | Supporting option text. |
error | string | — | Option-specific validation message. |
size | default | sm | xs | default | Visual size. |
value | string | on | Native option value. |
checked | boolean | — | Controlled standalone checked state. |
defaultChecked | boolean | false | Initial standalone checked state. |
onChange | ChangeEventHandler<HTMLInputElement> | — | Native radio change handler. |
disabled | boolean | false | Disables the option. |
required | boolean | false | Enables native required validation. |
name | string | group name | Standalone native group name. |
Other supported native radio input attributes are forwarded to the underlying <input>.