Radio Buttons

Radio buttons are used for selection of only one option from a group of values.

Each radio button group requires a minimum of 2 options to choose from.

Use a Select component if there are more than 6 options to choose from.

Only one option within a radio button group may be selected at one time, and one must be selected by the user (otherwise don't use radio buttons).

Although one of the options in a radio button group may be selected by default, it's recommended that none of them be selected by default so that users are more aware of the decision. Setting a default value can also discourage users from making conscious decisions, seem pushy, or alienate users who don’t fit into your assumptions.

Some radio button options may begin disabled until selections are made elsewhere on the page, while others may become disabled as the result of selections elsewhere. In such cases, the corresponding selection should be in view at the same time as the radio button group.

Radio buttons that are listed vertically are easier to read than those that are listed horizontally. Horizontal listings can make it difficult to tell which label pertains to which radio button.

Selecting a radio button should not trigger unexpected changes in context, such as causing significant changes to the page content or opening a new window

Keyboard Operation

  • Tab or Shift + Tab = Move focus into and out of the radio group. When focus moves into a radio group, if a radio button is checked, focus is set on the checked button. If none of the radio buttons are checked, focus is set on the first radio button in the group. In some browsers, if none of the radio buttons are selected, moving focus into the radio group with Shift + Tab will place focus on the last radio button instead of the first radio button.
  • Space = Checks the focused radio button if it is not already checked.
  • Right Arrow or Down Arrow = Move focus to the next radio button in the group, uncheck the previously focused button, and check the newly focused button. If focus is on the last button, focus moves to the first button.
  • Left Arrow or Up Arrow = Move focus to the previous radio button in the group, uncheck the previously focused button, and check the newly focused button. If focus is on the first button, focus moves to the last button.

Do's and Don'ts

Types

Variants

Error State

A form validation checks user input against success criteria before passing the data to the server. If there is a problem with the data then the system generates an error to help the user complete their task. An error notification is displayed at top of page, and any radio button groups that are in error are visually indicated.


Error State

Common Button Labels and Usage

Title case, 2-3 words maximum.
Do not combine actions in a label (exception: "Customize & Buy").
If standard labels don't fit the button's purpose, align label with the task the user is attempting.

Please refer to the Dell Technologies branding website, https://brand.delltechnologies.com/faq/#voice, for further information regarding call-to-action labels and usage.

Button Label:
Corresponding Action:
Add to Cart
Search
Cancel
Save
Edit
Delete
Continue
Next/Previous
Submit
Select
Sign In/Sign Out
View Details
Ok/Cancel
Learn More
Close
Takes users to Cart page, with item added
Used for search buttons
Takes users back to entry point for a task
Used to save an item
Navigates users to change an item
Deletes an item on the page, usually with a verification step
Used as progression
Used as forward and backward navigation (Next is primary, Previous is secondary)
Used to submit a task or info
Used for choosing items in a task flow
Authentication standard, for consistency do not use Log In/Log Out or Signin/Signout
Used instead of “Select” in cases of product details or within learn content
For use in modal verification steps when more specific CTAs will not fit due to space
Used to link users to more learning content or contextual help
Used within modal windows

Radio Buttons

Standard Radio Buttons with Optional Title

<fieldset> <legend class="dds__mb-1"> Sample Standard Radio Buttons Title (Optional) </legend> <!-- // temporary class (dds-radio-button) for radio buttons to make the
// click area bigger. should do the same for other
// form inputs. Delaying that because of potential
// confilcts with another story that's being worked on
// Mar 21, 2019 -->
<div class="dds__form-check"> <label class="dds__form-check-label" for="stndRadio1"> <input class="dds__form-check-input" type="radio" name="exampleRadios" id="stndRadio1" value="standardopt1"> <span>Value 1</span> </label>
</div>
<div class="dds__form-check"> <label class="dds__form-check-label" for="stndRadio2"> <input class="dds__form-check-input" type="radio" name="exampleRadios" id="stndRadio2" value="standardopt2"> <span>Value 2</span> </label>
</div>
<div class="dds__form-check dds-radio-button"> <label class="dds__form-check-label" for="exampleDisabledRadio"> <input class="dds__form-check-input" type="radio" name="exampleRadios" id="exampleDisabledRadio" value="option3" disabled=""> <span>Value 3 (disabled)</span> </label>
</div> </fieldset>

Inline Radio Buttons with Optional Title

<fieldset> <legend class="dds__mb-1"> Sample Inline Radio Buttons Title (Optional) </legend> <div class="dds__form-check dds__form-check-inline"> <label class="dds__form-check-label" for="exampleRadios1"> <input class="dds__form-check-input" type="radio" name="exampleInline" id="exampleRadios1" value="option1"> <span>Value 1</span> </label>
</div>
<div class="dds__form-check dds__form-check-inline"> <label class="dds__form-check-label" for="exampleRadios2"> <input class="dds__form-check-input" type="radio" name="exampleInline" id="exampleRadios2" value="option2"> <span>Value 2</span> </label>
</div>
<div class="dds__form-check dds__form-check-inline"> <label class="dds__form-check-label" for="exampleRadios3"> <input class="dds__form-check-input" type="radio" name="exampleInline" id="exampleRadios3" value="option3" disabled=""> <span>Value 3 (disabled)</span> </label>
</div> </fieldset>

Radio Buttons with Optional Title in Error State

<fieldset> <legend class="dds__mb-1"> Sample Standard Radio Buttons Title (Optional) </legend>
<div class="dds__alert-styling"> <div class="dds__form-check"> <label class="dds__form-check-label" for="stndRadio1"> <input class="dds__form-check-input" type="radio" name="exampleRadios" id="stndRadio1" value="standardopt1"> <span>Value 1</span> </label>
</div>
<div class="dds__form-check"> <label class="dds__form-check-label" for="stndRadio2"> <input class="dds__form-check-input" type="radio" name="exampleRadios" id="stndRadio2" value="standardopt2"> <span>Value 2</span> </label>
</div>
<div class="dds__form-check dds-radio-button"> <label class="dds__form-check-label" for="exampleDisabledRadio"> <input class="dds__form-check-input" type="radio" name="exampleRadios" id="exampleDisabledRadio" value="option3" disabled=""> <span>Value 3 (disabled)</span> </label>
</div> </div> <div class="dds__invalid-feedback"> Error message goes here. </div> </fieldset>

No items found.

No items found.

No items found.

Redlines

Accessibility Goals

  • People with cognitive disabilities can better understand the form and how to complete it, as making forms accessible improves the layout structure, instructions, and feedback.
  • People using speech input can use the labels via voice commands to activate controls and move the focus to the fields that they have to complete.
  • People with limited dexterity benefit from large clickable areas that include the labels, especially for smaller controls, such as radio buttons and checkboxes.
  • People using screen readers can identify and understand form controls more easily because they are associated with labels, field sets, and other structural elements.

Design Accessibility

A minimum touch target of 34 pixels in height should be used to assist with touchscreen interaction.

Provide instructions within labels to help users understand how to complete the form and individual form controls. Providing instructions outside of labels allows more flexible positioning and design, but sometimes it can be missed. It is also not supported by some web browsers (typically older versions) and assistive technologies that don’t implement WAI-ARIA.

Validate input (radio button selected) by the user and provide options to undo changes and confirm data entry.

Notify users about successful task completion, any errors, and provide instructions to help them correct mistakes.

Development for Accessibility

Users should be able to select a radio button by clicking on the button directly and by clicking on its label. This is useful to some with motor disabilities.

Use the <label> element, and in specific cases other mechanisms (e.g. WAI-ARIA, title attribute etc.), to identify each form control.

Matching for="name" and id="name" values associate the label with the appropriate form control.

Because id must be unique on each page, only one label can be associated to each unique form element. This means you cannot have one label for multiple form elements. Additionally, screen readers do not support multiple labels that are associated to the same form element.

As a best practice, each radio button group should make use of <fieldset> (a tag that's used to group related elements in a form) and <legend> (a tag that defines a heading for the <fieldset> element). This is especially true for forms submitting data. Nested fieldsets should generally be avoided. In screen readers, the legend text is generally read for each control in the fieldset, so the legend text should be brief and descriptive. (see Inputs for more details)

The aria-required attribute informs assistive technologies about required controls so that they are appropriately announced to the users (as opposed to validating the input). Most current web browsers automatically set its value to true when the HTML5 required attribute is present.

The radiogroup role defines a container for a set of ARIA radio buttons.

The label for the radio group is defined using aria-labelledby attribute.

The labels for the radio buttons are defined by the text nodes of each radio button.

The radio button that is currently selected is identified using aria-checked=“true”.

Only one radio button can be selected at a time, all other radio buttons should define aria-checked as “false".

A div element with role radio has onkeydown event to support keyboard activation of the radio.

A div element with role radio has tabindex="0" to become part of the tab order of the page.

Each radio has tabindex="-1" except one.

CSS Generated Content is used to visually indicate the state of radio (e.g. checked, unchecked). To ensure the visual state will be visible when browsers or operating system use “High Contrast” settings by people with visual impairments; the visuals are created in CSS rather than via the use of a background image. (Note: CSS background image techniques result in visual state disappearing when browsers or operating systems are configured to display high contrast themes.)

The setRadioButton function uses aria-checked attribute to make sure the information communicated to assistive technology is the same as the visual state. (e.g. img element).

The onfocus and onblur event handlers on radio support provide visual focus styling for keyboard only users.

If the submitted data contains errors, it is convenient to set the focus to the first <input> element that contains an error.

See this ARIA radiogroup and radio example for more info.

References

  • 1.3.1 Info and Relationships: Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text. (Level A)
  • 2.4.6 Headings and Labels: Headings and labels describe topic or purpose. (Level AA)
  • 3.3.2 Labels or Instructions: Labels or instructions are provided when content requires user input. (Level A)
  • 4.1.2 Name, Role, Value: For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies. (Level A)