Skip to main content

Radio group

Radio groups display a related set of options where only one option can be selected.

Code documentation

Web

Anatomy

The radio group component is made up of six elements.

  1. Label
  2. Required indicator
  3. Helper text
  4. Control
  5. Default slot
  6. Error text
Anatomy diagram numbering six elements of a radio group.

Variants

Label

Radio groups can include a label that describes the related controls.

Two radio groups are compared side-by-side. The one on the left includes a label above three vertically stacked radios with labels. The group on the right does not include a label.

Helper text

Helper text can be included to convey additional information about the controls.

Sample helper text is displayed between the radio group label and a series of vertically stacked radios.

Default slot

The default slot accommodates any number of radios that are contextually related.

A blue rectangle highlights the position of the default slot immediately below the radio group label.

Required indicator

Radio groups can be marked as either required or optional which triggers relevant validation on the form. The indicator is a preset and styled element within the component, not manually entered as part of the label string.

Required form elements are used when the majority of the form elements are optional, but a few need to be marked as required.

Optional form elements are used when the majority of the form elements are required, but a few elements need to be marked as optional.

Two radio groups are compared side-by-side. The left group includes an indicator styled as a red asterisk to the right of the group label. The right group includes an indicator with the word optional in parentheses to the right of the group label.

Orientation

Radio groups can be either vertical or horizontal depending on the layout requirements of the user interface. The default orientation is vertical.

Two radio groups compare different ways of orienting the radios. The top example vertically stacks three radios with labels. The bottom example includes the three radios horizontally oriented under the group label.

Behavior

Invalid

An invalid state can be triggered on radio groups to indicate that a value needs to be entered or that the entered value is invalid. Error text is always displayed as part of the invalid state to allow for a generic error message or provide specific guidance as to what needs to be fixed. Error text is always displayed in addition to any helper text that is present and below the default slot.

A sample of red error text is displayed immediately below three vertically stacked radios.

Text overflow

Label

Label text that is longer than the available space wraps to a new line.

The radio group label text wraps to a second line when it meets the edge of an implied container around the radio group.

Helper and error text

Helper and error text wrap to a new line when they are too long for available horizontal space.

The helper and error text of the radio group each wrap to a second line when they meet the edge of an implied container around the group.