Bedform UIControls

Radio

The base component for Radio Group.

Usage

import { Radio } from "@bedform/ui/radio";

<Radio name="mode" value="survival" defaultChecked>
  Survival
</Radio>;

Group radios in a Radio Group. Radio is also exported from @bedform/ui/radio-group.

Colors

<Radio color="primary" defaultChecked>Primary</Radio>
<Radio color="secondary" defaultChecked>Secondary</Radio>
<Radio color="destructive" defaultChecked>Destructive</Radio>
<Radio color="dungeons" defaultChecked>Dungeons</Radio>
<Radio color="legends" defaultChecked>Legends</Radio>
<Radio color="realms" defaultChecked>Realms</Radio>
<Radio color="gold" defaultChecked>Gold</Radio>

States

<Radio name="mode" value="survival" defaultChecked>
  Survival
</Radio>
<Radio name="mode" value="hardcore" disabled>
  Hardcore
</Radio>

Radios with the same name and form are mutually exclusive.

Events

Selecting a new option dispatches native input and change events, so onChange works as it does on any input.

API

Radio renders a native radio input inside a label, and its children become the label text. It accepts every attribute of a radio input, such as checked, defaultChecked, disabled, name, required and value, and its ref points to the input.

PropTypeDefault
color"primary" | "secondary" | "destructive" | "dungeons" | "legends" | "realms" | "gold""primary"
labelClassNamestring—

CSS variables

VariablePurpose
--ore-radio-unitBase size unit
--ore-radio-backgroundUnselected background
--ore-radio-highlightUnselected highlight
--ore-radio-borderBorder color
--ore-radio-indicator-lightIndicator light color
--ore-radio-indicator-dimIndicator midtone color
--ore-radio-indicator-darkIndicator dark color
--ore-radio-active-backgroundSelected background
--ore-radio-active-background-hoverSelected hover background
--ore-radio-active-background-pressedSelected pressed background
--ore-radio-active-highlightSelected highlight
--ore-radio-active-highlight-hoverSelected hover highlight
--ore-radio-active-highlight-pressedSelected pressed highlight

Accessibility

The native radio input provides radio semantics, form behavior, and validation. Use arrow keys to move within a same-name group and Space to select the focused option.

On this page