Custom Checkbox and Toggle Switch CSS Generator (Accessible)

Generates the HTML and CSS for a styled checkbox or toggle switch that keeps the native input, so keyboard and screen reader behaviour stay intact.

Use the tool

Why this tool exists

Hiding the real checkbox and drawing a fake one with a span breaks keyboard focus and screen reader support more often than people notice.

This generator keeps the native input and restyles it with appearance: none. The output includes a visible focus ring, a disabled state, a prefers-reduced-motion override and a forced-colors fallback. The switch variant adds role="switch" so assistive technology announces it as a switch.

How to use it

  1. Choose checkbox or switch.
  2. Set size, colours, radius and transition.
  3. Check the preview.
  4. Copy the HTML and CSS.

Frequently asked questions

Why keep the real input?

It gives you keyboard support, form submission and the correct accessible role for free.

Does it work in all browsers?

appearance: none is supported in current browsers. Very old ones show the default control.

Can I use my own colours?

Yes, any plain CSS colour. Check contrast of the on and off states against the page background.