Radio Group
Allows users to select a single option from a list of mutually exclusive choices.
Structure
API Reference
The radio group component used to group radio items under a common name for form submission.
Property | Type | Description |
---|---|---|
value bindable prop | string | The value of the currently selected radio item. You can bind to this value to control the radio group's value from outside the component. Default: undefined |
onValueChange | function | A callback that is fired when the radio group's value changes. Default: undefined |
disabled | boolean | Whether or not the radio group is disabled. This prevents the user from interacting with it. Default: false |
required | boolean | Whether or not the radio group is required. Default: false |
name | string | The name of the radio group used in form submission. If provided, a hidden input element will be rendered to submit the value of the radio group. Default: undefined |
loop | boolean | Whether or not the radio group should loop through the items when navigating with the arrow keys. Default: false |
orientation | enum | The orientation of the radio group. Default: 'vertical' |
ref bindable prop | HTMLDivElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-orientation | enum | The orientation of the radio group. |
data-radio-group-root | —— | Present on the root element. |
An radio item, which must be a child of the RadioGroup.Root
component.
Property | Type | Description |
---|---|---|
disabled | boolean | Whether or not the radio item is disabled. This prevents the user from interacting with it. Default: false |
value Required | string | The value of the radio item. This should be unique for each radio item in the group. Default: undefined |
ref bindable prop | HTMLButtonElement | The underlying DOM element being rendered. You can bind to this to get a reference to the element. Default: undefined |
children | Snippet | The children content to render. Default: undefined |
child | Snippet | Use render delegation to render your own element. See delegation docs for more information. Default: undefined |
Data Attribute | Value | Description |
---|---|---|
data-disabled | —— | Present when the radio item is disabled. |
data-value | —— | The value of the radio item. |
data-state | enum | The radio item's checked state. |
data-orientation | enum | The orientation of the parent radio group. |
data-radio-group-item | —— | Present on the radio item element. |