HTML Toggle Switch Builder
Builds an iOS-style toggle switch with label using <input type=checkbox> and inline CSS.
Toggle switch markup you can style
You need an on/off switch in a screen and you would rather not pull in an entire CSS framework for it. The native HTML checkbox already behaves correctly, it just does not look like a switch. The sensible route is to keep the real checkbox and restyle its appearance, and that is exactly what comes out of this page.
Type the label text, write yes or no for the initial state, and the output is an inline-flex label with the input inside it and the text beside it. The input carries appearance:none, a 36 by 20 pixel box, a grey background, and rounded corners. Be clear about the limit: there is no checked-state rule and no sliding knob, so the pill looks the same grey whether it is on or off. You get the skeleton and finish the visuals yourself.
To make it behave like a switch, move the snippet into a stylesheet and add two rules: one on input:checked to change the background, and an ::after pseudo-element for the knob that slides with a transform. Pseudo-elements cannot live in an inline style attribute, which is why they are missing here. Keep the label wrapping the input, since that is what makes the text clickable and names the control. Label text is not escaped, so fix any quotes or angle brackets first. It all builds in the browser.
Frequently asked questions
Why does my toggle not change color when clicked?
Can I pick colors or sizes in the tool itself?
Is this pattern accessible?
Related Tools
HTML Form Builder
Builds a <form> with inputs from a list of name:type entries and configurable action/method.
HTML Rating Stars Builder
Builds a sequence of filled/empty stars representing a numeric rating from 0 to 5.
Iframe Builder
Builds a generic <iframe> with src, width, height and optional sandbox/allow attributes.
Tel Link Builder
Build clickable tel: links from a phone number in the international E.164 format. Great for call buttons on mobile sites, email signatures and contact pages.
Img Srcset Builder
Builds an <img> tag with a responsive srcset from URLs and widths, ideal for fluid images.
Character Info
Get full information about any Unicode character: decimal code, hex, HTML entity, UTF-8 and official name. Click any character to inspect it.