Components
Radio
A Radio is an option the user can select. Use multiple Radio to show a list of options. Users can switch between the options, but can only select one.
React
Unable to parse html
const Preview = () => { return <Radio label='Radio' value='value' name='name' />; }; render(<Preview />)
Use Radio when
- the user must choose one of several options in a form
Avoid Radio when
- the user should be able to choose more than one option, use
Checkboxinstead
Example
Grouping
Use a legend to ask the question, and include a description if additional explanation is needed.
React
Unable to parse html
const GroupEn = () => { return ( <Fieldset> <Fieldset.Legend>How would you like us to contact you?</Fieldset.Legend> <Fieldset.Description> Choose the method that works best for you. We use this only to send important updates about your case. </Fieldset.Description> <Radio label='Email' description='We will use the email address you provided earlier (name@example.com)' value='email' name='contact' /> <Radio label='SMS' description='We will use the phone number you provided earlier (99 99 99 99)' value='sms' name='contact' /> <Radio label='Letter' description='Delivery may take 3-5 working days, depending on the postal service.' value='letter' name='contact' /> </Fieldset> ); }; render(<GroupEn />)
With error
If the user attempts to continue without answering a required question, the error message should apply to the entire group of options.
React
Unable to parse html
const WithErrorEn = () => { return ( <Fieldset> <Fieldset.Legend>Which district do you live in?</Fieldset.Legend> <Fieldset.Description> Trondheim is divided into four districts </Fieldset.Description> <Radio label='Østbyen' value='ostbyen' name='city' aria-invalid='true' /> <Radio label='Lerkendal' value='lerkendal' name='city' aria-invalid='true' /> <Radio label='Heimdal' value='heimdal' name='city' aria-invalid='true' /> <Radio label='Midtbyen' value='midtbyen' name='city' aria-invalid='true' /> <ValidationMessage data-color='danger'> You must choose a district before you can continue. </ValidationMessage> </Fieldset> ); }; render(<WithErrorEn />)
Guidelines
Use Radio when users must select only one option. If they need to select more, use Checkbox.
There should not be more than seven options in one group. If users need more choices, consider using Suggestion or Select. If there is only one choice to make, a Switch or a Checkbox may be more suitable.
Sorting
Sort options alphabetically unless there is a clear reason not to. Be careful about placing the most common option first if the question is personal or value-based, such as sexual orientation or political affiliation.
Placement
Place radio buttons vertically whenever possible. This makes the list easier to scan and the options easier to read. For users who need to zoom in, horizontal layouts can be challenging.
When using a horizontal layout, it must be clear which text belongs to which button. You can use a horizontal layout when there are only two options with short labels, such as “Yes” and “No”, or in a rating scale ranging from “strongly disagree” to “strongly agree”. Likert scale (snl.no).
React
Unable to parse html
const InlineEn = () => { return ( <Fieldset> <Fieldset.Legend>Contact by email?</Fieldset.Legend> <Fieldset.Description> Confirm whether you would like to be contacted by email. </Fieldset.Description> <div style={{ display: 'flex', flexWrap: 'wrap', gap: 'var(--ds-size-6)' }} > <Radio name='my-inline' label='Yes' value='yes' /> <Radio name='my-inline' label='No' value='no' /> </div> </Fieldset> ); }; render(<InlineEn />)
Be cautious with preselected options
Consider whether a preselected option is appropriate for the context. A preselected option can influence the user's ability to make an informed choice, and some users may experience it as manipulative or discriminatory.
Text
A group with multiple options should always have a legend and option labels. Both can include a description to provide additional explanation. When the description is intended to help users understand the question and provide necessary information before they make a choice, it should be placed directly after the legend.
Do
Don't
Answer options should be as short as possible, and each option should follow the same linguistic form.
Edit this page on github.com (opens in a new tab)