Radio
An easily stylable radio button component.
View as MarkdownAnatomy
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>API reference
RadioGroup
Provides a shared state to a series of radio buttons. Renders a <div> element.
namestring
—
namestring
—- Name
 - Description
 Identifies the field when a form is submitted.
- Type
 string | undefined
defaultValueunknown
—
defaultValueunknown
—- Name
 - Description
 The uncontrolled value of the radio button that should be initially selected.
To render a controlled radio group, use the
valueprop instead.- Type
 unknown
valueunknown
—
valueunknown
—- Name
 - Description
 The controlled value of the radio item that should be currently selected.
To render an uncontrolled radio group, use the
defaultValueprop instead.- Type
 unknown
onValueChangefunction
—
onValueChangefunction
—- Name
 - Description
 Callback fired when the value changes.
- Type
 | (( value: unknown, eventDetails: Radio.Group.ChangeEventDetails, ) => void) | undefined
styleReact.CSSProperties | function
—
styleReact.CSSProperties | function
—- Name
 - Type
 | React.CSSProperties | ((state: RadioGroup.State) => CSSProperties | undefined) | undefined
disabledboolean
false
disabledboolean
false
- Name
 - Description
 Whether the component should ignore user interaction.
- Type
 boolean | undefined- Default
 false
readOnlyboolean
false
readOnlyboolean
false
- Name
 - Description
 Whether the user should be unable to select a different radio button in the group.
- Type
 boolean | undefined- Default
 false
requiredboolean
false
requiredboolean
false
- Name
 - Description
 Whether the user must choose a value before submitting a form.
- Type
 boolean | undefined- Default
 false
inputRefRef<HTMLInputElement>
—
inputRefRef<HTMLInputElement>
—- Name
 - Description
 A ref to access the hidden input element.
- Type
 React.Ref<HTMLInputElement> | undefined
classNamestring | function
—
classNamestring | function
—- Name
 - Description
 CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
 | string | ((state: RadioGroup.State) => string | undefined)
renderReactElement | function
—
renderReactElement | function
—- Name
 - Description
 Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
 | ReactElement | (( props: HTMLProps, state: RadioGroup.State, ) => ReactElement)
data-disabled
Present when the radio group is disabled.
Root
Represents the radio button itself.
Renders a <button> element and a hidden <input> beside.
value*any
—
value*any
—- Name
 - Description
 The unique identifying value of the radio in a group.
- Type
 any
nativeButtonboolean
true
nativeButtonboolean
true
- Name
 - Description
 Whether the component renders a native
<button>element when replacing it via therenderprop. Set tofalseif the rendered element is not a button (e.g.<div>).- Type
 boolean | undefined- Default
 true
styleReact.CSSProperties | function
—
styleReact.CSSProperties | function
—- Name
 - Type
 | React.CSSProperties | ((state: Radio.Root.State) => CSSProperties | undefined) | undefined
disabledboolean
—
disabledboolean
—- Name
 - Description
 Whether the component should ignore user interaction.
- Type
 boolean | undefined
readOnlyboolean
—
readOnlyboolean
—- Name
 - Description
 Whether the user should be unable to select the radio button.
- Type
 boolean | undefined
requiredboolean
—
requiredboolean
—- Name
 - Description
 Whether the user must choose a value before submitting a form.
- Type
 boolean | undefined
inputRefRef<HTMLInputElement>
—
inputRefRef<HTMLInputElement>
—- Name
 - Description
 A ref to access the hidden input element.
- Type
 React.Ref<HTMLInputElement> | undefined
classNamestring | function
—
classNamestring | function
—- Name
 - Description
 CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
 | string | ((state: Radio.Root.State) => string | undefined)
renderReactElement | function
—
renderReactElement | function
—- Name
 - Description
 Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
 | ReactElement | (( props: HTMLProps, state: Radio.Root.State, ) => ReactElement)
data-checked
Present when the radio is checked.
data-unchecked
Present when the radio is not checked.
data-disabled
Present when the radio is disabled.
data-readonly
Present when the radio is readonly.
data-required
Present when the radio is required.
data-valid
Present when the radio is in valid state (when wrapped in Field.Root).
data-invalid
Present when the radio is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the radio's value has changed (when wrapped in Field.Root).
data-touched
Present when the radio has been touched (when wrapped in Field.Root).
data-filled
Present when the radio is checked (when wrapped in Field.Root).
data-focused
Present when the radio is focused (when wrapped in Field.Root).
Indicator
Indicates whether the radio button is selected.
Renders a <span> element.
styleReact.CSSProperties | function
—
styleReact.CSSProperties | function
—- Name
 - Type
 | React.CSSProperties | (( state: Radio.Indicator.State, ) => CSSProperties | undefined) | undefined
classNamestring | function
—
classNamestring | function
—- Name
 - Description
 CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
 | string | ((state: Radio.Indicator.State) => string | undefined)
keepMountedboolean
false
keepMountedboolean
false
- Name
 - Description
 Whether to keep the HTML element in the DOM when the radio button is inactive.
- Type
 boolean | undefined- Default
 false
renderReactElement | function
—
renderReactElement | function
—- Name
 - Description
 Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
 | ReactElement | (( props: HTMLProps, state: Radio.Indicator.State, ) => ReactElement)
data-checked
Present when the radio is checked.
data-unchecked
Present when the radio is not checked.
data-disabled
Present when the radio is disabled.
data-readonly
Present when the radio is readonly.
data-required
Present when the radio is required.
data-valid
Present when the radio is in valid state (when wrapped in Field.Root).
data-invalid
Present when the radio is in invalid state (when wrapped in Field.Root).
data-dirty
Present when the radio's value has changed (when wrapped in Field.Root).
data-touched
Present when the radio has been touched (when wrapped in Field.Root).
data-filled
Present when the radio is checked (when wrapped in Field.Root).
data-focused
Present when the radio is focused (when wrapped in Field.Root).
Examples
Form integration
To use a radio group in a form:
- Pass the group’s 
nameto<Field> - Use the 
renderprop to compose<Fieldset>and<RadioGroup> - Use 
<Field.Item>to wrap each radio in the group 
<Form>
  <Field.Root name="shipping">
    <Fieldset.Root render={<RadioGroup />}>
      <Fieldset.Legend>Shipping method</Fieldset.Legend>
      <Field.Item>
        <Field.Label>
          <Radio.Root value="standard" />
          Standard
        </Field.Label>
      </Field.Item>
      <Field.Item>
        <Field.Label>
          <Radio.Root value="express" />
          Express
        </Field.Label>
        ` `{' '}
      </Field.Item>
    </Fieldset.Root>
  </Field.Root>
</Form>