Animated Bubble Toggle Switch with Pure HTML and CSS
If you’re looking for a visually captivating way to design a toggle switch without using JavaScript, this animated bubble-style toggle switch made entirely with HTML and CSS is a perfect solution. It offers a modern, smooth animation that enhances the user interface of any website.
This toggle animation features an organic, “blob-like” movement that transforms beautifully when toggled. The switch morphs between two states — inactive and active — with animated rotation and color changes, creating a professional and interactive experience.
How It Works
This toggle switch is built using only three HTML elements:
A hidden
<input>checkboxA
<label>styled as a bubbleA container
<div>for layout
When the checkbox is checked or unchecked, CSS animations are triggered to transition the bubble’s position, shape, and color. The use of @keyframes makes the animation smooth and expressive, and :checked selectors control the switch state.
Key Features
1. No JavaScript Required
This switch relies completely on HTML and CSS. The hidden checkbox input acts as the state manager, while sibling selectors in CSS (#bubble:checked + .bubble) handle all visual transitions.
2. Blob-like Movement
The animation mimics a “liquid” stretching and snapping effect as the toggle transitions between sides. This effect is created using:
Border-radius manipulations
CSS transitions
Keyframe animations
3. Morphing Check Icon
On switching, two white bars rotate and shift to form a check mark. This is handled using CSS ::before and ::after pseudo-elements.
4. Customizable Colors
You can easily update the toggle’s active and inactive colors:
Default (gray):
#BBBBBBActive (green):
#3CCC97
Just change these values in the CSS to match your brand.
Where to Use This Toggle
This animated bubble switch is ideal for:
Dark mode/light mode toggles
On/off controls in settings menus
Signup form preferences
Any UI requiring a custom toggle without JavaScript
Why Choose a CSS-Only Toggle?
Using a CSS-only toggle reduces dependencies, improves loading time, and works great in static sites or environments where JavaScript isn’t preferred (like email templates or minimal frameworks).
Final Thoughts
This bubble toggle switch with animation proves how powerful CSS alone can be for creating rich, dynamic interfaces. It’s lightweight, responsive, and visually engaging — perfect for developers and designers aiming for modern, fluid UI without extra libraries.
This code uses HTML and CSS only — no JavaScript included.
Copyright – 2025 https://codepen.io/onediv/pen/pjgNqJ
Permission is freely granted to anyone who obtains a copy of this software and its accompanying documentation files (referred to as “the Software”), allowing them to use, copy, modify, merge, publish, distribute, sublicense, and even sell copies of the Software. Additionally, users are allowed to permit others to use the Software under these same terms.
It is required that the above copyright notices and this permission notice be included in all versions or significant portions of the Software.
Please note, the Software is provided “as is”, without any form of warranty—express or implied. This includes, but is not limited to, warranties of merchantability, fitness for a specific purpose, or non-infringement. Under no circumstances shall the original authors or rights holders be held responsible for any claims, damages, or other liabilities that may arise from the use of the Software, whether through legal action, negligence, or otherwise.
All code on Freeofcosts.com is reviewed before publishing. Each post includes a live code editor with real-time preview, so you can experiment and learn by doing. Most code is open-source and free to use or modify under respective licenses.



