Loading...
Installation
Install the following dependencies:
Copy and paste the following code into your project.
Loading...
Update the import paths to match your project setup.
Composition
RadioGroup ├── RadioGroupLabel (optional) └── RadioGroupItem ├── RadioGroupItemControl │ └── RadioGroupIndicator ├── RadioGroupItemText └── RadioGroupItemHiddenInput
Examples
Default
Loading...
Grid
Loading...
Invalid
Loading...
List
Loading...
API Reference
RadioGroup
| Prop | Type | Default | Description |
|---|---|---|---|
id | string | undefined | — | Unique identifier used to connect the component parts. |
ids | ElementIds | undefined | — | Overrides generated identifiers for individual parts. |
value | string | null | undefined | — | Current value when the component is controlled. |
defaultValue | string | null | undefined | — | Initial value when the component is uncontrolled. |
name | string | undefined | — | Name used when submitting the value with a form. |
form | string | undefined | — | Associates the control with a form by ID. |
disabled | boolean | undefined | false | Disables interaction with the component. |
invalid | boolean | undefined | — | Marks the associated form control as invalid. |
required | boolean | undefined | false | Marks the associated form control as required. |
readOnly | boolean | undefined | false | Prevents changes while preserving focus and navigation. |
onValueChange | ((details: ValueChangeDetails) => void) | undefined | — | Runs when value changes. |
orientation | "horizontal" | "vertical" | undefined | "horizontal" | Sets the component orientation and keyboard navigation axis. |
Context, Hooks, and Types
| Export | API |
|---|---|
RadioGroupContext | Render-prop component that exposes component state and actions. |
RadioGroupRootProvider | Provides an externally created API to the component tree. |
useRadioGroup | Creates or accesses the component API. |
useRadioGroupContext | Returns the nearest component API. |
RadioGroupValueChangeDetails | Type for the details object passed to the matching change callback. |
Angular
React
Solid
Svelte
Vue