Skip to main content

Radio

BasicSelection<co-radio>

Radio and RadioGroup choose exactly one option from a short visible list.

import { Radio } from 'health-components';

Examples​

Showcase​

Storybook

Inline​

Storybook

With Error​

Storybook

Disabled​

Storybook

Single Radio​

Storybook

Usage​

<RadioGroup label="Visit Mode" inline required options={["In person", "Telehealth"]} value={mode} onChange={setMode} />

When to use​

  • Two to six options that need explanation: "Text message", "Authenticator app".

When not to use​

  • Many options: Select.
  • A compact view switch: SegmentedControl.

Variants and states​

VariantWhat it is
verticalDefault, one per line with optional description.
inlineOptions in a row.
errorMessage under the group.
disabled optionGreyed.

Accessibility​

  • Fieldset with legend; arrow keys move between options natively.

Do and don't​

  • Do: Describe the cost of each choice: "Card on file (Visa ending 4242)".
  • Don't: A radio group with one option.

Props​

PropTypeDefaultDescription
label *ReactNode—Visible label; the whole row is clickable. Required
descriptionReactNodenoneHelp text under the label
disabledbooleanfalseDisables the radio

Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, onChange, onInput, readOnly, name, value, max, step, placeholder, accept, autoComplete, checked, maxLength, min, multiple, required, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-radio>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-radio disabled default-checked [defaultValue]="defaultValue" (co-change)="onChange($event.detail)"></co-radio>
KindNameDescription
attributedisabledDisables the radio; default false
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
attributeread-only / readOnly
attributename
property / JSON attributevalue
property / JSON attributemax
property / JSON attributestep
attributeplaceholder
attributeaccept
property / JSON attributeauto-complete / autoComplete
attributechecked
attributemax-length / maxLength
property / JSON attributemin
attributemultiple
attributerequired
eventco-change (React: onChange)
eventco-input (React: onInput)
slotlabelVisible label; the whole row is clickable. Required Plain text also works as the `label` attribute.
slotdescriptionHelp text under the label; default none Plain text also works as the `description` attribute.