Switch
Overview
The Switch component is a form input element used to toggle a single setting or option on and off. It supports flexible label orientations, allowing the label to appear on the left or right of the Switch. Switches are ideal for binary decisions that take immediate effect, providing visual feedback through interactive states like hover, active, and focus.
Live demo
Usage
Do
Use a Switch for binary, immediate actions such as enabling or disabling a feature.
Label the Switch clearly to describe what is being toggled.
Position the label to the left or right of the Switch, ensuring it remains visible unless there is a strong reason to hide it.
Provide immediate feedback when the state of the Switch changes.
Don't
Avoid using a Switch for actions that require confirmation or multi-step processes.
Do not use a Switch for navigation or triggering unrelated actions.
Avoid hiding the label unless the context provides enough clarity for users (e.g., the Switch is within a well-labelled group).
Placement
The Switch component can be placed anywhere on a page where user interaction is required, such as in forms, navigation bars, or call-to-action sections.
Place the Switch close to the related content or within a settings section for clear context.
Align the Switch with other form elements for a consistent layout.
Label Orientation
Hidden Label: Use sparingly. Designers must ensure the meaning of the Switch remains clear without the label, relying on strong contextual cues or supporting text.
States and interactions
The Switch component has several interactive states, including enabled, hover, active, focus, and disabled.
Each state can be customised with different properties and colour tokens to provide visual feedback to the user.
| Example | State | When to use |
|---|---|---|
| Enabled |
| |
| Hover |
| |
| Focus |
| |
| Active |
| |
| Disabled |
|
Disabled Switch
Exercise caution with Disabled Switchs and consider alternatives, such as enabling Switchs and validating information upon submission, accompanied by clear error information.
Disabled Switchs can cause confusion and frustration for users, leading to high abandonment rates and increased support inquiries.
Accessibility
Use ARIA attributes to announce the Switch’s state to screen readers (e.g., aria-checked).
Ensure the Switch can be toggled using keyboard controls.
Provide clear focus styles to enhance usability for keyboard users.
If the label is hidden, ensure the accessible name is programmatically available via ARIA or similar mechanisms.
iOS guidance
Along with the guidance above, there is some iOS specific guidance for this component.
Adhere to Apple's Human Interface Guidelines (HIG) for iOS design principles and recommendations.
Ensure compatibility with iOS Dynamic Type for accessible text scaling.