Radio Group
A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time.
Installation
npm i @huin-core/react-radio-groupAPI Reference
RadioGroup
| Prop | Type | Description |
|---|---|---|
| asChild | boolean | When set to true, renders the component as its child element, inheriting the child's styles and behavior. |
| defaultValue | — | Specifies the initial value of the component when it is first rendered, before any user interaction or dynamic updates. |
| value | string | Represents the current value or state of the component, which can be used to bind or track its data over time. |
| onValueChange | function | Event handler called when the value changes. |
| disabled | boolean | When set to true, disables the component, preventing user interaction or triggering of associated actions. |
| name | string | The name of the piece. |
| required | boolean | When true, indicates that the user must check the switch before the owning form can be submitted. |
| orientation | "vertical" | "horizontal" | Specifies the direction or layout of the component, determining whether it is displayed vertically or horizontally. |
| dir | "ltr" | "rtl" | The reading direction. If omitted, inherits globally from DirectionProvider or assumes LTR (left-to-right) reading mode. |
| loop | boolean | When true, keyboard navigation will loop from last item to first, and vice versa. |
RadioGroupItem
| Prop | Type | Description |
|---|---|---|
| asChild | boolean | When set to true, renders the component as its child element, inheriting the child's styles and behavior. |
| value | string | Represents the current value or state of the component, which can be used to bind or track its data over time. |
| disabled | boolean | When set to true, disables the component, preventing user interaction or triggering of associated actions. |
| checked | boolean | Represents the current state of the component, indicating whether it is enabled or selected. |
| name | string | The name of the piece. |
RadioGroupIndicator
| Prop | Type | Description |
|---|---|---|
| asChild | boolean | When set to true, renders the component as its child element, inheriting the child's styles and behavior. |
| forceMount | boolean | Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. It inherits from. |
Keyboard Interactions
| Key | Description |
|---|---|
Tab | Moves focus into the group, onto the checked item. |
ArrowDown ArrowRight | Moves to and checks the next item. |
ArrowUp ArrowLeft | Moves to and checks the previous item. |