Start a project

Tool 113 of 450 · Form controls

CSS Toggle Switch Generator

Design an accessible toggle switch on a real checkbox with size, colours and motion, and copy the HTML and CSS.

CSS Toggle Switch Generator

Your input

Result

    HTML
    CSS

    01

    What it does

    Design an accessible toggle switch on a real checkbox with size, colours and motion, and copy the HTML and CSS.

    • Real checkbox with role="switch": keyboard, forms and screen readers work
    • Width, height, shape, colours and speed
    • Visible focus ring with :focus-visible
    • prefers-reduced-motion support

    02

    Private by design

    Everything happens in your browser. Nothing you type, paste or upload is sent anywhere, and it keeps working offline once the page has loaded.

    03

    What you get

    Live switch, HTML, CSS and accessibility checks, with a Copy and a Download button on every result.

    • Toggle switch
    • Forms
    • Accessibility

    Why it matters

    Most CSS toggles hide the checkbox with display:none, which removes it from the keyboard and screen readers. This one keeps the real input and styles a track and knob around it.

    It also checks that the knob and track stand out enough (3:1 for UI parts) and that the target is at least 24 by 24 pixels.

    How to use it

    1. Type or paste your input; the example shows the format.
    2. Press Build switch. Results also update as you type.
    3. Read the summary line, then the table, notes or output below it.
    4. Copy or download what you need. Nothing leaves this page.

    FAQ

    Checkbox or button with aria-pressed?

    Use a checkbox with role="switch" when it's part of a form or a setting that saves; it gets a name, state and keyboard support for free.

    Why is there no JavaScript?

    The checkbox holds the state, and CSS :checked styles it. Add a change listener only if you need to save the setting.

    What contrast does a switch need?

    WCAG 1.4.11 asks for 3:1 between the parts that show state (track and knob) and what's next to them.

    Is my input uploaded?

    No. The tool runs in your browser and nothing you type, paste or open is sent anywhere.

    Can I rely on the result?

    It follows the public specification or formula named on this page and says where it simplifies. Check anything critical against the official tool or documentation before you ship it.

    Work with me

    Want a site that gets these right?

    I build fast, accessible websites and web apps that pass these checks from day one. Tell me about your project and I'll reply personally with honest next steps.

    All developer tools · Back to leej.uk