Retro Power Switch with LED Indicator Using HTML and CSS
Modern websites often feature simple toggles and sliders, but sometimes, you want something that stands out — something that feels physical, interactive, and a little nostalgic. In this tutorial, you’ll learn how to create a realistic, retro-inspired power switch with glowing LED indicators using only HTML and CSS.
Overview of the Switch Design
This power switch mimics the look and feel of a physical toggle, complete with:
Realistic gradients and shadows
ON and OFF LED lights (green and red)
3D-style handle and housing
Smooth animation transitions
Fully functional input checkbox
No JavaScript is needed — the entire behavior is controlled through well-structured CSS.
How the Switch Works
The switch is built around an HTML checkbox input element. With some advanced CSS styling and positioning, this checkbox transforms into a fully animated switch. Here’s what happens when you interact with it:
When toggled ON, the green LED lights up and the handle moves upward.
When toggled OFF, the red LED glows and the handle shifts downward.
Each part — borders, handles, shadows, and lights — is styled to simulate depth and realism.
This switch is perfect for creative websites, interactive UI showcases, or even educational projects.
Core Components
HTML Structure
The HTML uses several <span> layers nested inside a main container. These spans represent the borders, handle, LED lights, and shadow overlays. A hidden checkbox input controls the toggle action using the :checked selector in CSS.
Advanced CSS Styling
Gradients and inset shadows simulate metal and plastic textures.
Absolute positioning places each layer precisely.
Transitions add a smooth toggle effect.
LED indicators change glow colors depending on the switch state.
Why Use This Toggle Switch?
Here’s what makes this toggle switch design special:
Fully Customizable: You can change colors, sizes, or even replace the LED colors with different states like “Active” / “Sleep”.
JavaScript-Free: Everything is done in CSS — making it lightweight and ideal for performance-conscious designs.
Visually Engaging: It grabs attention and adds character to your UI.
Use Cases
This switch UI can be used in:
Control panels on dashboard UIs
Device simulation interfaces
Dark mode/light mode toggles with a visual twist
Retro-themed websites or projects
Educational websites that demonstrate electronics or CSS power
Final Thoughts
This power toggle switch design proves how far you can push CSS to build realistic, complex UIs — all without a single line of JavaScript. It combines visual depth, interactive motion, and functional elements in one beautifully styled component.
This code uses HTML and CSS only — no JavaScript included.
Copyright – 2025 https://codepen.io/bhargavmdubal/pen/wvQBMqQ
Copyright – 2025 csemszepp
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.



