Radio

Choose exactly one option from a small, visible set. Radio is a native radio input; RadioGroup supplies the shared name, the selected value and arrow-key navigation.

StableSource

Import

tsx
import { Radio, RadioGroup } from "@merid/react";

Examples

Controlled, with descriptions

defaultValue makes the group uncontrolled. For controlled use pass value and onValueChange, which receives the new value as a string. description adds a linked second line.

3–5 business daysNext business day
value: standard

Horizontal

Disabled and invalid

disabled on the group disables every radio; on a single Radio it disables just that option, which arrow keys then skip. invalid marks the group with aria-invalid and turns the circles red.

API reference

RadioGroup

Renders a div with role="radiogroup"; the ref and other div attributes are forwarded.

PropTypeDefaultDescription
valuestring–Selected value (controlled).
defaultValuestring–Initially selected value (uncontrolled).
onValueChange(value: string) => void–Called with the new value when the selection changes.
namestring–Form field name shared by every radio. Generated when omitted.
orientation"vertical" | "horizontal""vertical"Layout direction.
disabledbooleanfalseDisables every radio in the group. Inside a `Field`, inherited from it.
requiredbooleanfalseMarks the group required for form validation. Inside a `Field`, inherited from it.
invalidbooleanfalseMarks the group invalid (`aria-invalid`; `data-invalid` on the group and each input). Inside a `Field`, derived from its `error`.
childrenReactNode–Radio elements.

Radio

The ref and native input attributes go to the <input>; className and style go to the outer wrapper.

PropTypeDefaultDescription
valueRequiredstring–Value submitted and reported to RadioGroup.onValueChange.
childrenReactNode–Visible label next to the circle.
descriptionReactNode–Secondary line under the label, linked via aria-describedby.
disabledboolean–Disables this radio. Defaults to the group's disabled.

Styling

HookValues
.mrd-radio-groupGroup container; data-orientation = vertical · horizontal
.mrd-radioRadio wrapper; data-disabled when disabled
.mrd-radio__control, __input, __circleNative input and its drawn circle
.mrd-radio__text, __label, __descriptionLabel column
data-invalidOn the group and each input; styles the circles as invalid

Radio has no component variables.

Accessibility

  • The group has role="radiogroup". Name it with aria-label or aria-labelledby pointing at a visible heading. Inside a Field, it is named by the Field label and picks up its description, error, required and disabled state.
  • The group is a single tab stop: Tab lands on the selected radio (or the first one when nothing is selected).
  • Arrow keys move focus and selection together and wrap at the ends; disabled radios are skipped. Left/Right are mirrored in right-to-left layouts.
KeyAction
TabMoves focus into the group, onto the selected radio.
↓→Selects the next enabled radio, wrapping to the first.
↑←Selects the previous enabled radio, wrapping to the last.
HomeSelects the first enabled radio.
EndSelects the last enabled radio.
SpaceSelects the focused radio if it is not already selected.

Guidelines

Do

Use radios for two to six options that people should compare side by side, with a sensible default selected.

Avoid

Use radios for long lists — use NativeSelect — or for a single yes/no, which is a checkbox.