Skip to content
Mesh
4.3.4

Radio

Radio buttons are used for a list of two or more options when a user can only select one option. If there are seven or more options use a dropdown menu instead.

Installation

bash
npm install @nib-components/radio

As a form input, @nib-components/form-control must wrap this component to provide an accessible label, help text, and validation styling.

Usage

jsx
import Radio from '@nib-components/radio';

Interactive demo

Label
jsx

Props

As the <Radio/> is wrapped in a <FormControl/>, all FormControl props such as valid, validated, and disabled will be passed down to this component. This includes the id, name and label which will align with the for attribute on the <label>.

All props passed directly to <Radio/> will be applied to the underlying <input> as attributes.

PropTypeDefaultDescription
value (required)stringThe input value.
label (required)stringThe input label.
selectedbooleanfalseWhether the input is selected.

Target

The user can select the radio button by clicking the radio circle directly or by clicking on its label. Therefore links cannot be included in radio button labels. The target container height for each radio option is 56px. This large target size makes it easy for users to select/unselect the option, even if they are using a touch screen device or have limited dexterity.

Default selection

By default, no option is selected. Requiring the user to select the relevant option reduces data entry errors.

Radio container length and display

On desktop and ipad devices the length of the radio option container will be dependant on the length of the text; the container padding remains the same.

Radio options are displayed inline by default. This can be toggled via the inline prop.

On mobile and small screens (480px of less) radio options are full-width and stacked. This allows users to easily reach and select options.

Stacked, full-width radios on small screens

Labels

Labels help the user understand what option to select. Labels are short, concise and use sentence-style capitalisation.

Optional controls

Denote optional controls by adding “(Optional)" to the end of the label.

Help text

Help text is an instruction that supports a user to make an accurate selection. It can also be used to clarify how the information will be used. It is optional and should only be used where needed.

Help text should appear below the label and above the radio options. Use sentence-style capitalisation and concise sentence/s.

Accessibility best practices for help text

  • Help text displayed above the radio options allows screen readers to read the help information before the user makes a selection.