Radio
An easily stylable radio button component.
API reference
Radio is always placed within Radio Group. Import the components and place them together:
import { Radio } from '@base-ui-components/react/radio';
import { RadioGroup } from '@base-ui-components/react/radio-group';
<RadioGroup>
<Radio.Root>
<Radio.Indicator />
</Radio.Root>
</RadioGroup>
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
defaultValue | any | undefined | |
disabled | boolean | false | |
name | string | undefined | |
onValueChange | (value, event) => void | undefined | |
readOnly | boolean | false | |
render | | React.ReactElement | undefined | |
required | boolean | false | |
value | any | undefined |
Attribute | Description | |
---|---|---|
data-disabled | Present when the radio group is disabled. |
Root
Represents the radio button itself.
Renders a <button>
element and a hidden <input>
beside.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
disabled | boolean | false | |
readOnly | boolean | false | |
render | | React.ReactElement | undefined | |
required | boolean | false | |
value | any | undefined |
Attribute | Description | |
---|---|---|
data-checked | Present when the radio is checked. | |
data-dirty | Present when the radio's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the radio is disabled. | |
data-invalid | Present when the radio is in invalid state (when wrapped in Field.Root). | |
data-readonly | Present when the radio is readonly. | |
data-required | Present when the radio is required. | |
data-touched | Present when the radio has been thouched (when wrapped in Field.Root). | |
data-unchecked | Present when the radio is not checked. | |
data-valid | Present when the radio is in valid state (when wrapped in Field.Root).. |
Indicator
Indicates whether the radio button is selected.
Renders a <span>
element.
Prop | Type | Default | |
---|---|---|---|
className | string | (state) => string | undefined | |
keepMounted | boolean | true | |
render | | React.ReactElement | undefined |
Attribute | Description | |
---|---|---|
data-checked | Present when the radio is checked. | |
data-dirty | Present when the radio's value has changed (when wrapped in Field.Root). | |
data-disabled | Present when the radio is disabled. | |
data-invalid | Present when the radio is in invalid state (when wrapped in Field.Root). | |
data-readonly | Present when the radio is readonly. | |
data-required | Present when the radio is required. | |
data-touched | Present when the radio has been thouched (when wrapped in Field.Root). | |
data-unchecked | Present when the radio is not checked. | |
data-valid | Present when the radio is in valid state (when wrapped in Field.Root). |