defaultValuedisabledreadOnlyimport { Radio, RadioGroup } from "@/components/ui/radio"
export function DensityPicker() {
return (
<RadioGroup aria-label="Density" defaultValue="comfortable">
<label className="flex items-center gap-2">
<Radio value="default" />
Default
</label>
<label className="flex items-center gap-2">
<Radio value="comfortable" />
Comfortable
</label>
<label className="flex items-center gap-2">
<Radio value="compact" />
Compact
</label>
</RadioGroup>
)
}Usage
import { Radio, RadioGroup } from "@/components/ui/radio"
export function PlanPicker() {
return (
<RadioGroup aria-label="Plan" defaultValue="free">
<label className="flex items-center gap-2">
<Radio value="free" />
Free
</label>
<label className="flex items-center gap-2">
<Radio value="pro" />
Pro
</label>
</RadioGroup>
)
}Examples
import { Radio, RadioGroup } from '@/components/ui/radio';
export function Example() {
return (
<RadioGroup defaultValue="comfortable">
<label className="flex items-center gap-2">
<Radio value="default" />
<span className="text-sm font-medium">Default</span>
</label>
<label className="flex items-center gap-2">
<Radio value="comfortable" />
<span className="text-sm font-medium">Comfortable</span>
</label>
<label className="flex items-center gap-2">
<Radio value="compact" />
<span className="text-sm font-medium">Compact</span>
</label>
</RadioGroup>
);
}Selected: email
import React from 'react';
import { Radio, RadioGroup } from '@/components/ui/radio';
export function Example() {
const [value, setValue] = React.useState('email');
return (
<div className="space-y-3">
<RadioGroup value={value} onValueChange={setValue}>
<label className="flex items-center gap-2">
<Radio value="email" />
<span className="text-sm font-medium">Email</span>
</label>
<label className="flex items-center gap-2">
<Radio value="sms" />
<span className="text-sm font-medium">SMS</span>
</label>
<label className="flex items-center gap-2">
<Radio value="push" />
<span className="text-sm font-medium">Push Notification</span>
</label>
</RadioGroup>
<p className="text-sm text-muted-foreground">Selected: {value}</p>
</div>
);
}import { Radio, RadioGroup } from '@/components/ui/radio';
export function Example() {
return (
<RadioGroup defaultValue="active" disabled>
<label className="flex items-center gap-2 text-muted-foreground">
<Radio value="active" />
<span className="text-sm font-medium">Active</span>
</label>
<label className="flex items-center gap-2 text-muted-foreground">
<Radio value="inactive" />
<span className="text-sm font-medium">Inactive</span>
</label>
</RadioGroup>
);
}Notes
Radio labels
Wrap each Radio and its text in a <label>. Clicking the text picks the radio, and the agent reads the text as the option's name. Without a label it falls back to aria-label, then the value.
Built-in indicator
Radio already renders a RadioIndicator; do not add one inside it. The export is for custom radios built on the Base UI primitive.
API
details.cancel() refuses the change.onValueChange receives. Required for the agent to list the radio.Agent
Inside an AgentProvider, it appears in agent.snapshot() as radio-group.
Reads
labelThe group's aria-label or aria-labelledby.
valueThe checked radio's label, or an empty string.
itemsEvery radio's label, in document order.
disabledTrue when the whole group is blocked.
Actions
select("Compact")Picks by label, then by value. A miss lists the options.
An agent's change runs through onValueChange. isAgentChange(details) is true for it, and details.cancel() refuses it; the agent is told the app refused. A disabled radio, a disabled group and readOnly refuse on their own.
await agent.act({
steps: [{ ref: "radio-group", action: "select", args: ["Compact"] }],
})Accessibility
- The group is a radiogroup; each radio is a radio with aria-checked.
- Name the group with aria-label or aria-labelledby. The agent reads the same name.
- Enter does not check a radio; only Space and the arrow keys do.
- A hidden input submits the value with a native form.