A radio group enables the user to select one option from a mutually-exclusive list.
A radio group enables the user to select one option from a list of multiple, mutually-exclusive options. It offers the same basic functionality as a select menu, but does not require the user to interact to see the list of options.
Use a radio group when:
If you have a long list of options, consider using a select menu instead. If the user can select more than one option, use a checkbox group instead.
Note: once a user has made a selection, they cannot return a radio group to its unselected state. You can work around this by providing an additional null option (eg. "none of the above".)
An error message can also be displayed below the description when needed.
Radio groups support the following states:
Design system components are published in a Figma library. Install the library and add it to your project to start using this component.
A radio group has two parts:
Each part has its own set of controls.
If your use case requires hiding the group label, you must also provide a non-visible label using the aria-label property.
Control | Options | Description |
---|---|---|
Style |
|
Toggles between selected and unselected states |
State |
|
Toggles between different interaction states |
Selected |
|
Toggles between selected and unselected states |
Show label |
|
Toggles display of text label to the right of the radio |
Control | Options | Description |
---|---|---|
Count | Number |
Sets number of options displayed |
Layout |
|
Sets orientation of radio group |
Label |
|
Toggles display of the label above the input |
Description |
|
Toggles display of the description below the input |
Error text |
|
Toggles display of the error message field below the description |
Detailed technical documentation, interactive previews and code samples are published in the B.C. Design System Storybook.
A reference implementation of the radio group component in React is published in the React components library. Install the package via npm to start using the component.
The component is comprised of two subcomponents:
The radio group component is a styled version of the React Aria RadioGroup. It uses the Radio subcomponent to populate individual list items. Each component has its own set of props.
Refer to the React Aria documentation for detailed information about:
These summaries reflect the component used as provided. If you modify it, confirm that your changes comply with the Web Content Accessibility Guidelines (WCAG). B.C. government digital services are required to meet the WCAG Level AA standard.
Requirement | WCAG Success Criterion | Validation |
---|---|---|
Make sure visual formatting is represented in the backend code | 1.3.1 (Level A) |
Group label and list are automatically associated via an aria-labelledby attribute |
Clearly define the purpose of input fields | 1.3.5 (Level AA) |
The radio group has a visible label, used to explain its purpose Note: if you do not use the label property, you must use aria-label to provide a semantic label |
Make websites keyboard accessible | 2.1.1 (Level A) |
Radio group is focusable and fully operable using only the keyboard, with visual indicators for focused elements |
Prevent keyboard navigation traps | 2.1.2 (Level A) |
When in focus, the user can exit the radio group by pressing the 'Tab' key |
Ensure content reads in the right order for people using assistive technology | 2.4.3 (Level A) |
Focus moves through list options vertically from top to bottom |
Show where the keyboard is active on the screen | 2.4.7 (Level AA) |
Focused elements are indicated with an offset border ring |
Make sure components can be read and used by assistive technology | 4.1.2 (Level A) |
Group label and list are automatically associated via an aria-labelledby attribute. The list has the "radiogroup" role |