Radio Group
FormGroup of radio buttons for single-select from multiple options.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import {
RadioGroup,
RadioGroupItem,
} from "@dashboardpack/core/components/ui/radio-group";
import { Label } from "@dashboardpack/core/components/ui/label";
import { useState } from "react";
export default function RadioGroupExample() {
const [plan, setPlan] = useState("Team");
return (
<div className="space-y-4">
<RadioGroup
value={plan}
onValueChange={setPlan}
aria-label="Subscription plan"
>
{["Starter", "Team", "Enterprise"].map((name) => (
<div key={name} className="flex items-center gap-3">
<RadioGroupItem id={`plan-${name}`} value={name} />
<Label htmlFor={`plan-${name}`}>{name}</Label>
</div>
))}
</RadioGroup>
<p className="text-sm text-muted-foreground">Selected: {plan}</p>
</div>
);
}Usage
Use a radio group for one choice from a short list. Render RadioGroupItem with a unique id and a Label for each option.
import {
RadioGroup,
RadioGroupItem,
} from "@dashboardpack/core/components/ui/radio-group";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| value / defaultValue | stringDefault: — | Controlled or initial selected value. |
| onValueChange | (value: string) => voidDefault: — | Handle selection changes. |
| orientation | horizontal | verticalDefault: — | Set keyboard navigation orientation. |
| disabled | booleanDefault: false | Disable the group. |