gnome-ui
Components

Radio

An accessible and stylable radio button. `Radio.Root` renders a `<span>` with a hidden `<input>` next to it — always wrapped in a `<label>` for maximum accessibility. `RadioGroup` manages shared state.

Radio component

Billing plan

    import { Radio } from "gnome-ui/radio";
    import { RadioGroup } from "gnome-ui/radio-group";

    export function RadioGroupBasic() {
      return (
        <RadioGroup defaultValue="system" aria-label="Theme">
          {["Light", "Dark", "System"].map((label) => (
            <label key={label}>
              <Radio.Root value={label.toLowerCase()}>
                <Radio.Indicator />
              </Radio.Root>
              {label}
            </label>
          ))}
        </RadioGroup>
      );
    }

Controlled

Use value + onValueChange to control state externally. Individual options accept disabled.

Notifications

Selected: mentions

RadioIndicator

Indicates whether the radio button is selected. Renders a &lt;span&gt; element.

Documentation: Base UI Radio

API reference

RadioGroup

Provides a shared state to a series of radio buttons. Renders a <div> element.

Provides a shared state to a series of radio buttons. Renders a <div> element.

RadioGroup Props:

PropTypeDefaultDescription
namestring-Identifies the field when a form is submitted.
defaultValueValue-The uncontrolled value of the radio button that should be initially selected.To render a controlled radio group, use the value prop instead.
valueValue-The controlled value of the radio item that should be currently selected.To render an uncontrolled radio group, use the defaultValue prop instead.
onValueChange((value: Value, eventDetails: Radio.Group.ChangeEventDetails) => void)-Callback fired when the value changes.
disabledbooleanfalseWhether the component should ignore user interaction.
readOnlybooleanfalseWhether the user should be unable to select a different radio button in the group.
requiredbooleanfalseWhether the user must choose a value before submitting a form.
inputRefRef<HTMLInputElement>-A ref to access the hidden input element.
classNamestring | ((state: RadioGroup.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: RadioGroup.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: RadioGroup.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

RadioGroup Data Attributes:

AttributeTypeDescription
data-disabled-Present when the radio group is disabled.

Root

Represents the radio button itself. Renders a <span> element and a hidden <input> beside.

Root Props:

PropTypeDefaultDescription
valueValue-The unique identifying value of the radio in a group.
nativeButtonbooleanfalseWhether the component renders a native <button> element when replacing it via the render prop. Set to true if the rendered element is a native button.
disabledboolean-Whether the component should ignore user interaction.
readOnlyboolean-Whether the user should be unable to select the radio button.
requiredboolean-Whether the user must choose a value before submitting a form.
inputRefRef<HTMLInputElement>-A ref to access the hidden input element.
classNamestring | ((state: Radio.Root.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Radio.Root.State) => CSSProperties | undefined)--
renderReactElement | ((props: HTMLProps, state: Radio.Root.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

Root Data Attributes:

AttributeTypeDescription
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.

Indicator Props:

PropTypeDefaultDescription
classNamestring | ((state: Radio.Indicator.State) => string | undefined)-CSS class applied to the element, or a function that returns a class based on the component’s state.
styleCSSProperties | ((state: Radio.Indicator.State) => CSSProperties | undefined)--
keepMountedbooleanfalseWhether to keep the HTML element in the DOM when the radio button is inactive.
renderReactElement | ((props: HTMLProps, state: Radio.Indicator.State) => ReactElement)-Allows you to replace the component’s HTML element with a different tag, or compose it with another component.Accepts a ReactElement or a function that returns the element to render.

Indicator Data Attributes:

AttributeTypeDescription
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).

On this page