Radio Group
A set of checkable buttons where only one can be checked at a time.
Usage
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"
import { Field, FieldLabel } from "@/components/ui/field"<RadioGroup defaultValue="option-one">
<Field orientation="horizontal">
<RadioGroupItem value="option-one" id="option-one" />
<FieldLabel htmlFor="option-one">Option One</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="option-two" id="option-two" />
<FieldLabel htmlFor="option-two">Option Two</FieldLabel>
</Field>
</RadioGroup>Examples
Disabled
{/* Whole group disabled */}
<RadioGroup defaultValue="default" disabled>
<Field orientation="horizontal" data-disabled="true">
<RadioGroupItem value="default" id="default" />
<FieldLabel htmlFor="default">Default</FieldLabel>
</Field>
<Field orientation="horizontal" data-disabled="true">
<RadioGroupItem value="comfortable" id="comfortable" />
<FieldLabel htmlFor="comfortable">Comfortable</FieldLabel>
</Field>
</RadioGroup>
{/* Individual item disabled */}
<RadioGroup defaultValue="comfortable">
<Field orientation="horizontal" data-disabled="true">
<RadioGroupItem value="default" id="default" disabled />
<FieldLabel htmlFor="default">Default</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="comfortable" id="comfortable" />
<FieldLabel htmlFor="comfortable">Comfortable</FieldLabel>
</Field>
</RadioGroup>With description
Perfect for individuals and small teams.
For growing businesses with advanced needs.
Dedicated support and custom integrations.
<RadioGroup defaultValue="starter">
<Field orientation="horizontal">
<RadioGroupItem value="starter" id="starter" />
<FieldContent>
<FieldLabel htmlFor="starter">Starter</FieldLabel>
<FieldDescription>Perfect for individuals and small teams.</FieldDescription>
</FieldContent>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="pro" id="pro" />
<FieldContent>
<FieldLabel htmlFor="pro">Pro</FieldLabel>
<FieldDescription>For growing businesses with advanced needs.</FieldDescription>
</FieldContent>
</Field>
</RadioGroup>Fieldset
<FieldSet>
<FieldLegend>Density</FieldLegend>
<RadioGroup defaultValue="comfortable">
<Field orientation="horizontal">
<RadioGroupItem value="default" id="default" />
<FieldLabel htmlFor="default">Default</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="comfortable" id="comfortable" />
<FieldLabel htmlFor="comfortable">Comfortable</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="compact" id="compact" />
<FieldLabel htmlFor="compact">Compact</FieldLabel>
</Field>
</RadioGroup>
</FieldSet>Invalid
<FieldSet>
<FieldLegend>Payment method</FieldLegend>
<RadioGroup aria-invalid>
<Field orientation="horizontal">
<RadioGroupItem value="card" id="card" />
<FieldLabel htmlFor="card">Credit card</FieldLabel>
</Field>
<Field orientation="horizontal">
<RadioGroupItem value="paypal" id="paypal" />
<FieldLabel htmlFor="paypal">PayPal</FieldLabel>
</Field>
</RadioGroup>
<FieldError>Please select a payment method.</FieldError>
</FieldSet>Card
$29 / month
$99 / month
<RadioGroup defaultValue="starter" className="grid gap-3">
<FieldLabel>
<Field orientation="horizontal">
<RadioGroupItem value="starter" id="starter" />
<FieldContent>
<FieldLabel htmlFor="starter">Starter</FieldLabel>
<FieldDescription>$9 / month</FieldDescription>
</FieldContent>
</Field>
</FieldLabel>
<FieldLabel>
<Field orientation="horizontal">
<RadioGroupItem value="pro" id="pro" />
<FieldContent>
<FieldLabel htmlFor="pro">Pro</FieldLabel>
<FieldDescription>$29 / month</FieldDescription>
</FieldContent>
</Field>
</FieldLabel>
</RadioGroup>Last updated on