Radio is a native input for choosing one option from a group. It works in forms without JavaScript and submits the selected value. Give radios the same name to make a group. Use the arrow keys to move between options.
Browser Support
Feature
Baseline
Your browser
appearance
Customizes the native radio appearance while retaining its browser behavior.
Your browser:
Preview
Installation
Usage
import { Radio } from "@/components/ui/radio"
import { Label } from "@/components/ui/label"
<fieldset>
<legend>Choose a plan</legend>
<div><Radio id="basic" name="plan" value="basic" defaultChecked /><Label htmlFor="basic">Basic</Label></div>
<div><Radio id="pro" name="plan" value="pro" /><Label htmlFor="pro">Pro</Label></div>
</fieldset>Examples
Disabled
<Radio id="disabled" disabled />
<Label htmlFor="disabled">Unavailable</Label>With a description
Arrives in three to five days.
<Radio id="delivery" name="delivery" aria-describedby="delivery-description" defaultChecked />
<Label htmlFor="delivery">Standard delivery</Label>
<p id="delivery-description">Arrives in three to five days.</p>Invalid state
Choose an option to continue.
<Radio id="choice" aria-invalid="true" aria-describedby="error" />
<Label htmlFor="choice">Choose an option</Label>
<p id="error">Choose an option to continue.</p>In a form
<form>
<fieldset>
<legend>Choose a plan</legend>
<div><Radio id="basic" name="plan" value="basic" defaultChecked /><Label htmlFor="basic">Basic</Label></div>
<div><Radio id="pro" name="plan" value="pro" /><Label htmlFor="pro">Pro</Label></div>
</fieldset>
<Button type="submit">Submit</Button>
</form>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| name | string | - | Shared name for the group and form field. |
| value | string | - | Value submitted when selected. |
| checked / defaultChecked | boolean | - | Controlled or initial selection. |
| disabled | boolean | - | Disables the input. |
| required | boolean | - | Requires a selection in the group. |
| aria-invalid | boolean | string | - | Marks the input as invalid. |
| ...props | InputHTMLAttributes<HTMLInputElement> | - | Other native input attributes, including onChange and aria attributes. |