Design a CSS toggle switch with a live preview. Pick colours, size and shape, then copy the HTML and CSS for your project.
Live preview (click it)
How to Use
- Pick the on, off and knob colours.
- Set the toggle width and shape.
- Type the label text.
- Try the live preview — click it to flip the switch.
- Press Copy HTML and CSS and paste the code into your page.
Key Features
- Live preview — a working toggle that updates as you design.
- Three shapes — pill, rounded or square.
- Pure CSS — no JavaScript needed in the generated code.
- Copy-ready — self-contained HTML and CSS snippet.
- 100% private — runs entirely in your browser; nothing is sent or stored.
FAQs
Does the generated code need JavaScript?
No. The toggle is pure HTML and CSS using a hidden checkbox, so it works anywhere.
How do I read the toggle state?
Give the checkbox a name and read it in your form handling, or listen for its change event in your own script.
Can I change the size later?
Yes — adjust the width and height values in the generated CSS. Keep the knob position rule in sync.
Is it accessible?
The snippet uses a real checkbox inside a label, so it works with keyboards and screen readers. Keep a meaningful label.
Is my data sent anywhere?
No. Everything runs entirely in your browser and never transmits or saves your entries.
Related Tools
Try these related tools: CSS Button Generator, CSS Card Generator and CSS Loader Generator.