Switch (Toggle)
A sliding control that turns a setting on or off immediately.
Also known as: Toggle
<input type="checkbox" role="switch">When to use it
For settings that apply instantly: dark mode, notifications.
Common mistake
Inside a form with a Save button, use a checkbox.
Accessibility
It applies instantly. If the change needs a Save button, use a checkbox instead.
Name in code
| HTML/CSS | <input type="checkbox" role="switch"> |
|---|---|
| React | <Switch> |
| Jetpack Compose | Switch |
| SwiftUI | Toggle |
Ready prompt for your coding agent
Add a Switch (Toggle) to this screen.
What it is: A sliding control that turns a setting on or off immediately.
Implement with: <input type="checkbox" role="switch"> (HTML/CSS).
Accessibility: It applies instantly. If the change needs a Save button, use a checkbox instead.
When to use it: For settings that apply instantly: dark mode, notifications.
Avoid: Inside a form with a Save button, use a checkbox.
Reuse the project's existing design tokens, spacing and component conventions.
Or compose a whole page from this element and others →
Prompts are in English for the most precise results with coding agents.