Skip to content

Radio

The Radio component lets people choose a single option from a set. It’s a compound component: Radio.Root provides the group context and manages selection, and each Radio.Item is a selectable option. Radio.Item must always be used inside a Radio.Root.

Variations

Optional

The radio group can be marked as optional via the optional prop on Radio.Root.

If the Radio.Root has a label, the optional indicator will appear next to the label.

If there’s no label, the optional indicator will be shown next to each individual radio item.

Disabled

The radio group can be marked as disabled via the disabled prop on Radio.Root, which disables all radio items within the group.

Alternatively, the disabled prop can be passed to individual Radio.Item to disable them selectively.

Error state

The radio group can be marked as error via the error prop on Radio.Root.

With tooltip

tooltipContent is used to display the content of the tooltip. tooltipProps is used to pass additional props to the tooltip.

Orientation

The Radio.Root component accepts an optional orientation prop, which defines the layout direction of the radio and its group label. Available options are horizontal and vertical (default).

Installation

import { Radio } from "@harnessio/ui/components";
function Example() {
const [group1Value, setGroup1Value] = React.useState("option1");
return (
<Radio.Root
label="Label text"
caption="Caption text"
value={group1Value}
onValueChange={setGroup1Value}
>
<Radio.Item value="option1" label="Option 1" caption="This is option 1" />
<Radio.Item value="option2" label="Option 2" caption="This is option 2" />
</Radio.Root>
);
}