Radio Buttons are circular actions used to make single-choice decisions.

Overview

Radio Buttons are designed to take up small interface area, which can fit within a multitude of workflows. Radio Buttons always have one selected item, denoted with a filled Brand color. You can use Radio Button Group as a convenient utility for layout and group configurations.

For "yes" and "no" interactions, multiple selections, and interactions where a choice is optional, please consider Checkbox. The key difference between a checkbox and radio is that radios must always have something active, whereas a checkbox is optional.

For "on" and "off" or boolean interactions, please consider Switch.

Sample

Usage

  • Various interactions where a single choice needs to be made
  • Forms

Component comparison

Radio Button, Checkbox, and Switch are similar, but each component is designed for a different purpose.

Radio ButtonThis component
Best for choosing a single option. Often used in a Radio Button Group with related options.
Allows only one option per Radio Button Group to be selected. Selection cannot be cleared.
CheckboxAlternative
Best for "yes" or "no" decisions.
Allows a choice to be selected or left unselected.
SwitchAlternative
Best for toggling a setting "on" or "off".
Allows only one option to be selected.

Accessibility

Form controls such as Radio Button should specify their labelText property or be accompanied by a Label component to provide context to assistive technologies. For additional information, refer to the forms and labels accessibility guidance.

Keyboard navigation

When Radio Buttons are presented with the same name property value, or contained in a Radio Button Group:

KeyFunction
Arrow leftMoves focus and selection to previous item. If the current focus and selection is the first item, the focus and selection will cycle to the last item.
Arrow rightMoves focus and selection to next item. If the current focus and selection is the last item, the focus and selection will cycle to the first item.
Arrow downMoves focus and selection to previous item. If the current focus and selection is the first item, the focus and selection will cycle to the last item.
Arrow upMoves focus and selection to next item. If the current focus and selection is the last item, the focus and selection will cycle to the first item.
TabMoves focus in and out of component.
Tab and ShiftMoves focus in and out of component.

Writing and copy

Correct Radio Button content length
Do prefer brevity in Radio Buttons.
Avoid Radio Button content length
Avoid tying Radio Button choices to long sentences or paragraphs.
  • Keep labels for Radio Buttons simple and succinct
  • Do not use contractions (you're, aren't, can't, haven't) for Radio Button labels in order to reduce confusion
  • Avoid writing Radio Button text as questions.

API reference

Properties

PropertyAttributeDescriptionTypeDefault
checkedcheckedWhen true, the component is checked.booleanfalse
disableddisabledWhen true, interaction is prevented and the component is displayed with lower opacity.booleanfalse
formformSpecifies the id of the component's associated form. When not set, the component is associated with its ancestor form element, if one exists.string
labelTextlabel-textSpecifies the component's label text.string
namenameSpecifies the name of the component. Required to pass the component's value on form submission.string
requiredrequiredWhen true and the component resides in a form, the component must have a value selected from the calcite-radio-button-group in order for the form to submit.booleanfalse
scalescaleSpecifies the size of the component inherited from the calcite-radio-button-group.Scale"m"
statusstatusSpecifies the status of the input field, which determines message and icons.Status"idle"
valuerequiredvalueThe component's value.any

Events

NameDescriptionBehavior
calciteRadioButtonChangeFires only when the radio button is checked. This behavior is identical to the native HTML input element. Since this event does not fire when the radio button is unchecked, it's not recommended to attach a listener for this event directly on the element, but instead either attach it to a node that contains all of the radio buttons in the group or use the calciteRadioButtonGroupChange event if using this with calcite-radio-button-group.bubblescomposed

Styles

NameDescription
--calcite-radio-button-background-colorSpecifies the component's background color.
--calcite-radio-button-border-colorSpecifies the component's border color.
--calcite-radio-button-corner-radiusSpecifies the component's corner radius.
--calcite-radio-button-sizeSpecifies the component's size.

Methods

NameDescriptionSignature
componentOnReadyCreates a promise that resolves once the component is fully loaded.componentOnReady(): Promise<this>
setFocusSets focus on the component.setFocus(options?: FocusOptions): Promise<void>
setValiditySets the component's validity state.setValidity(validity: ValidityStateFlags, validationMessage?: string): Promise<void>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.