Radio Group
A set of checkable buttons where only one can be checked at a time.
Installation
pnpm dlx cubix@latest add radio-group --base radixUsage
import { RadioGroup, RadioGroupItem } from "@/components/cubix/radio-group"<RadioGroup defaultValue="comfortable">
<RadioGroupItem value="default">Default</RadioGroupItem>
<RadioGroupItem value="comfortable">Comfortable</RadioGroupItem>
<RadioGroupItem value="compact">Compact</RadioGroupItem>
</RadioGroup>Examples
With description
Compose each radio with a title and supporting text for settings and plan pickers.
Disabled
Disable the whole group, or a single option.
Sizes
Horizontal
Set className="flex flex-row" to place options in a row.
API Reference
RadioGroup
The container that manages selection, the shared form name, and layout.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Controlled selected value. Use with `onValueChange`. |
| defaultValue | string | - | Initial selected value for uncontrolled usage. |
| onValueChange | (value: string) => void | - | Called with the next value whenever a radio is selected. |
| name | string | - | Shared name submitted with the form. Generated automatically when omitted. |
| disabled | boolean | false | Disables every radio in the group. |
| required | boolean | false | Marks the group as required for native form validation. |
| className | string | - | Additional Tailwind classes merged with the component styles (last one wins). |
| ...props | React.ComponentProps<'div'> | - | All native div attributes (id, aria-label, aria-labelledby, ...) are forwarded to the radiogroup. |
RadioGroupItem
A single option. Must be rendered inside RadioGroup. Pass children to render a label, or compose your own.
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | - | Value submitted when this radio is selected. Required. |
| disabled | boolean | false | Disables this radio independently of the group. |
| aria-invalid | boolean | false | When true, indicates the radio is in an invalid state. |
| className | string | - | Additional Tailwind classes merged onto the radio wrapper (last one wins). |
| ...props | React.ComponentProps<'input'> | - | All native radio attributes (id, form, tabindex, aria-*, ...) are forwarded to the rendered input. |
Variants
| Prop | Type | Default | Description |
|---|---|---|---|
| default | - | - | Checked state with primary background and a filled indicator. |
| disabled | - | - | Disabled radios cannot be interacted with. |