Toggle Switch

Toggle Switch allows users to toggle a boolean selection between states instantly. There is always a default selection for switches.

On this page

Anatomy

Toggle Anatomy
StateDescriptionRequired
LabelUsed to inform the user what they are switching on and off. Labels are required and need to be simple and easy to understand. Aria-label is also required for consistent identification, the same information is presented to all users. Learn more about label best practice.Yes
Toggle ControlA visual signifier to show the user whether the control is currently on or off by the background color. Wether the control is on or off its always visible.Yes
Hint TextCan be used to give more specific detail to support the labelOptional
Text Indicator“On” and “Off” text dynamically updates to state the intended behavior of the switch. User can change the text indicator. Remember that Text Indicator should be brief one word, like “on/off or show/hide”.Optional
Icon IndicatorUsed as a visual signifier to show active or inactive. User can change the icons.Optional
DividerUsed for making a list of toggle switches. Divider allows users to separates the individual toggle switch.Yes if used in a list

States

Toggle Anatomy
StateDescription
DefaultToggle Switch has a default state of either on or off. Recommendation is to have it turned off.
HoverControl elevation and border color change indicates to a user that the option is clickable.
PressedControl elevation and border color change indicates to a user that the option is being pressed.
ActiveThe active state indicates the switch is turned on.
Active HoverBackground color change indicates to a user that the option is clickable.
Active PressedBackground color change indicates to a user that the control is being pressed.
DisabledThe toggle switch isn’t interactive. Avoid using disabled, its best not to show it or an informative alternative on why its disabled. If you do choose to use a disable toggle switch, use aria-disabled=true instead of disabled, so it’s announced to screen reader users.
FocusA focus outline appears around visual element to help users identify current selected component. This is used when a user navigates using keyboard controls or uses a cursor. Focus will appear on all states, for more details review our focus state guidelines.

Questions?

Connect with the DLS Team on Slack or by email.

Resources

Check out additional resources.