Radio

A hand-drawn radio button, used inside a RadioGroup for single-selection.

Overview

A Radio represents one option in a single-select set. Used inside a RadioGroup, which derives each radio’s checked state from its own value and enforces mutual exclusivity.

Anatomy

A sketchy ring drawn behind a real <input type="radio"> (React/Web Components) or a Pressable with accessibilityRole="radio" (React Native). When checked, a second, smaller filled dot renders inside the ring, computed directly from @ghds/sketch-core and sharing the ring’s measured size and seed.

Variants & States

State Status Notes
Unchecked Implemented
Checked Implemented A filled dot renders inside the ring.
Disabled Implemented
Loading Not implemented

Usage

Do

  • Always use Radio inside a RadioGroup for real sets of mutually exclusive options.
  • Give every Radio in a group the same name (React/Web Components) — RadioGroup does this for you automatically.

Don't

  • Don't use a lone Radio outside a group to represent a single yes/no choice — use a Checkbox or Switch instead.
  • Don't expect Web Components' same-name radios to get automatic mutual exclusivity the way native radio inputs do — that's exactly what gh-radio-group exists to provide, since the platform doesn't do it for custom elements.

Accessibility

Content

The label names the option itself (“Small”, “Medium”, “Large”), not an action.

Props API

React@ghds/react

PropTypeDefaultDescription
labelstringVisible label, associated via Radix Label.
valuestringThis radio's own value — required.
checkedbooleanControlled checked state (standalone use).
defaultCheckedbooleanInitial checked state when uncontrolled and standalone.
disabledbooleanfalseDisables interaction.
...restInputHTMLAttributesAll other native input attributes pass through.

Web Components@ghds/web-components

PropTypeDefaultDescription
checkedbooleanfalseReflected attribute.
disabledbooleanfalseDisables interaction and form participation.
namestringSubmitted control name — repeat across a group.
valuestringThis radio's own value.
labelstringOptional visible label, also the accessible name.

React Native@ghds/react-native

PropTypeDefaultDescription
labelstringVisible, accessible label — required.
valuestringThis radio's own value — required.
checkedbooleanControlled checked state (standalone use).
defaultCheckedbooleanInitial checked state when uncontrolled and standalone.
onCheckedChange(checked: boolean) => voidFires when this radio becomes checked (standalone use).
disabledbooleanfalseDisables interaction.
testIDstringTest handle for queries.

Code examples

// React — @ghds/react
import { Radio } from '@ghds/react/radio';
import { RadioGroup } from '@ghds/react/radio-group';
import { useState } from 'react';

const [size, setSize] = useState('sm');
<RadioGroup label="Size" value={size} onValueChange={setSize}>
  <Radio label="Small" value="sm" />
  <Radio label="Medium" value="md" />
  <Radio label="Large" value="lg" disabled />
</RadioGroup>;
<!-- Web Components — @ghds/web-components -->
<!-- No group value: repeat `name` on each child; the group unchecks siblings -->
<script type="module">
  import '@ghds/web-components/radio';
  import '@ghds/web-components/radio-group';
</script>
<gh-radio-group label="Size">
  <gh-radio label="Small" name="size" value="sm" checked></gh-radio>
  <gh-radio label="Medium" name="size" value="md"></gh-radio>
  <gh-radio label="Large" name="size" value="lg" disabled></gh-radio>
</gh-radio-group>
// React Native — @ghds/react-native
import { Radio } from '@ghds/react-native/radio';
import { RadioGroup } from '@ghds/react-native/radio-group';

<RadioGroup label="Size" value={size} onValueChange={setSize}>
  <Radio label="Small" value="sm" />
  <Radio label="Medium" value="md" />
</RadioGroup>;

Live Demo

React and Web Components render live below, each wrapped in their own RadioGroup/<gh-radio-group>. React Native can’t run in a browser without additional react-native-web wiring, so its usage is shown as a code sample instead.

React @ghds/react

Web Components @ghds/web-components