Switches
Cross-platform differences
- Spectrum builds the Android switch as a standalone component without a label, aligning with the Material implementation. On iOS, Spectrum implements the switch as a list row with a label and optional icon, aligning with Apple's guidelines.
- Spectrum Android’s switch includes the minimum 48×48 dp tap target size outside the switch’s visual size, aligning with platform accessibility standards.
Anatomy
Component options
Is onTextIconIs on
This boolean option allows you to set the switch to “on” or “off.”
Enabled
This boolean option allows you to set the switch to be enabled or disabled. It applies to both the on and off states.
Text
This iOS-only option sets the row label that describes what the switch controls. The label is required.
Icon
This iOS-only option controls the presence of a leading icon that sits before the switch’s label.
Haptics & motion
- Switches support native OS haptic feedback when turned on or off.
- The thumb slides left or right as the user toggles the switch.
Usage guidelines
Do use within a list
In most cases, switches should be used within a list. They should always have an adjacent label for accessibility and clear comprehension.
Do use the correct selection control
Switches are best for communicating activation (e.g., turning a setting on or off). Checkboxes are best for communicating selection (e.g., selecting multiple items from a list). Radio buttons are best when only one option can be selected at a time from a set (e.g., choosing one preference or mode). On iOS, checkboxes and radio buttons aren't native controls. Multi-select and single-select are typically shown as list rows with a checkmark, or with pickers and segmented controls.
Internationalization
In right-to-left (RTL) languages such as Arabic and Hebrew, switches mirror their layout to match the reading direction.
Layout
- Label and icon: In RTL, the icon moves to the right edge and the label reads from right to left. In LTR, the icon sits on the left.
- Switch position (iOS): In LTR, the switch sits at the trailing (right) edge of the row. In RTL, it moves to the trailing (left) edge, opposite the label and icon.
Handle direction (iOS and Android)
- The handle sits at the leading edge when off and slides to the trailing edge when on.
- In LTR, the handle is on the left when off and on the right when on.
- In RTL, the handle is on the right when off and on the left when on.
Guidelines
- Mirror the layout of the label, icon, and switch for RTL languages.
- Don't mirror icons that don't carry directional meaning.
- Localize the label text. Allow room for translated strings that run longer than the English text.
Accessibility
Accessibility behaviors are built into the component to meet user preferences, including display scaling settings, TalkBack and VoiceOver compatibility, support for non-touch navigation modes, and accessible tap targets.
Additionally, teams will need to:
- Include an adjacent label that describes what the switch controls.
- On Android, maintain a minimum tap target area of 48dp × 48dp when laying out switches, even though their visual size is smaller. The Spectrum Android switch includes this tap target area by default in design and code. In cases where measuring or aligning to the switch's visual size matters, teams can also use Android's auto touch target expansion to measure or align the switch based on its visual size while still meeting the 48dp × 48dp minimum tap target requirement.