Skip to main content Home
About About the Design SystemRoadmap
Get started OverviewDesignersDevelopers
Foundations OverviewColorGridIconographyInteractionsSpacingTypography
Tokens Overview Global colorbox shadowTypographyborderopacityspacelengthIconBreakpointsMedia Queries
Elements All elements Accordion Alert Announcement Audio player Avatar Back to top Badge Blockquote Breadcrumb Button Card Chip Code block Call to action Dialog Disclosure Footer Health index Icon Jump links Navigation (primary) Navigation (secondary) Pagination PopoverPlanned Progress stepsPlanned Site status Skip link Spinner Statistic Subnavigation Surface Switch Table Tabs Tag Tile Timestamp Tooltip Video embed
Theming OverviewColor PalettesCustomizingDevelopers
Patterns All PatternsCardTabsFilterFormLinkLink with iconLogo wallSearch barSkip navigationSticky bannerSticky cardTileVideo thumbnail
Personalization All Personalization PatternsAnnouncement
Accessibility FundamentalsAccessibility toolsAssistive technologiesCI/CDContentContributorsDesignDevelopmentManual testingResourcesScreen readers
Design/code status Release notes Get support

Switch

OverviewStyleGuidelinesCodeAccessibilityDemos
Keyboard navigationFocus orderTouch targetsUsing form labelsScreen reader guidelinesARIA Authoring Practices Guide (APG)Web Content Accessibility GuidelinesKeyboard navigationFocus orderTouch targetsUsing form labelsScreen reader guidelinesARIA Authoring Practices Guide (APG)Web Content Accessibility Guidelines

Keyboard navigation

Users should have the ability to move focus to a Switch and toggle it on or off using their keyboard.

Diagram of switch with text and arrows that show what can be controlled by keyboard
Key Result
Tab Move focus to the Switch
Space Toggles the Switch on and off

Focus order

A logical focus order helps keyboard users operate our websites. Elements need to receive focus in an order that preserves meaning, therefore the focus order should make sense and not jump around randomly. If Switches are stacked, focus lands on each as it moves from top to bottom. Each Switch should have the ability to be toggled.

Diagram with four switches and numbers 1 to 4 indicating focus order

Touch targets

Grouped Switches are adequately spaced for optimal touch targets.

group of four switches and red circles with low opacity over each switch

Using form labels

Like other form elements, switches require labels that are available to assistive tech. These labels may be visible or visually hidden. A label captions its associated switch, offering an indication of its purpose (e.g., “Dark mode”). It’s important to note that a label is not the same as a status message (e.g., “On” and “Off”), and though it's associated with the switch and can control it, the label is not part of the Switch web component.

Visible labels

If you’re using a visible label, associate it with your switch:

  1. Ensure your <rh-switch> element has an id value.
  2. Add a <label> element before <rh-switch> with a for attribute pointing to the switch’s id.
<label for="my-switch">Switcheroo</label>
<rh-switch id="my-switch"></rh-switch>

Visually-hidden labels

If your label will not be visible, caption your switch via the accessible-label attribute.

<rh-switch accessible-label="Switcheroo"></rh-switch>

Screen reader guidelines

A Switch should communicate the following to users.

  • If a Switch is on or off
  • What the status messages say
  • What happens when a Switch is toggled

ARIA Authoring Practices Guide (APG)

Learn to use the accessibility semantics defined by the Accessible Rich Internet Application (ARIA) specification to create accessible web experiences.

View APG resources

Web Content Accessibility Guidelines

Understanding documents provide detailed explanations for Web Content Accessibility Guidelines (WCAG) guidelines and success criteria.

© 2021-2025 Red Hat, Inc. Deploys by Netlify