04.06 ยท Micro-Interactions
Toggle / Switch Slide
The knob slides across as the switch turns on or off. Best for settings.
Click it
Click or tap a switch to turn it on or off, or press Show me.
Inside, the top switch is pulled apart: a hidden checkbox holds on or off, the track changes color and the knob slides across. Click a switch, or press Show me.
Flips at once: the knob jumps and the color snaps; Slides across: the knob glides over, shown just after the click. Click a switch, or press Show me.
Try it
Change a setting, then try it again or press Show me.
Speed
Fast feels mechanical; slow can feel sluggish.
Feel
Gentle gives the knob weight; Even feels robotic.
Copy the prompt
Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.
Add an animated toggle switch to [the on/off setting you want to control]. Build it on a real checkbox so it works with the keyboard and screen readers. When it is turned on, the round knob slides across the track and the track fills with color; when it is turned off, both go back. When the settings ask for it, let the knob go slightly past the end and settle, so it feels springy. Make the whole switch and its label easy to tap. If the visitor has reduced motion turned on, move the knob without sliding. Match the settings listed below.
Your settings
Replace the words in brackets with your own element. Your settings are added at the end.
Free and open source. If this helped, a star on GitHub helps other people find it.
Star on GitHubWhat it is
The full explanation is in README.md.