A beautiful and customizable dark/light mode toggle switch with glowing sun and moon icons. Built using HTML, CSS, and JavaScript, this toggle is perfect for any website or web app needing theme switching functionality with visual flair.
- 🔘 Glowing circular toggle knob
- 🌞/🌙 Custom icon switching (sun for light mode, moon for dark mode)
- 🎨 Smooth animated transitions
- 🖼️ Theme-based background image switching
- 💡 Fully responsive and scalable (adjust size easily)
- 📦 No frameworks or dependencies — pure HTML/CSS/JS
You can view a live version here:
🔗 Live Demo
project/
├── index.html # Main HTML file
├── style.css # All styles including knob, icon, labels
├── icons/
│ ├── sun.png # Sun icon for light mode
│ └── moon.png # Moon icon for dark mode
└── images/
├── light-bg.jpg # Background for light theme
└── dark-bg.jpg # Background for dark theme
- Clone the repository or download the ZIP
- Add your own
sun.png
andmoon.png
icons in the/icons/
folder
(Recommended: 512×512px transparent PNG or SVG) - Add background images in
/images/
and update paths instyle.css
- Open
index.html
in your browser
You can adjust:
- Track size → Change
width
/height
of.toggle-track
- Knob size → Modify
.knob
width/height - Transition speed → Adjust
transition
properties - Background image per theme → Set
background-image
inbody
andbody.light-theme
- HTML5
- CSS3 (Flexbox, Transitions, Drop Shadow,media queries)
- Vanilla JavaScript
This project is open-source and free to use under the MIT License.
- Icons: Flaticon
- Backgrounds: Freepik
- Inspiration: Video Link