Toggles

Ready to use Tailwind CSS toggle components with production-ready, copy-paste HTML code. Use them as they are, or as a starting point to build beautiful websites.

Toggles are basically fancy on/off switches. They're better than a checkbox when you want the action to feel immediate, like flipping a setting, enabling a feature, or switching between two states. We have a standard toggle, a thinner/more compact version, toggles with a label on the left or right, and one with both a label and a description underneath. They all include the vanilla JavaScript to handle the click and aria-checked state, so they're accessible and work out of the box.

Tailwind

Frequently asked questions

A standard toggle, a thin/compact toggle, toggles with a label positioned on the left or right, and a toggle with both a label and a description for more context.

Yes, and it's already included. Each toggle component comes with vanilla JavaScript that handles the click, toggles the aria-checked attribute, and updates the visual state. Just copy the full snippet.

Toggles work best when the action feels like flipping a switch, think enabling dark mode, turning notifications on or off, or activating a feature. Checkboxes are better for selecting from a list of options.

Yes. They use role="switch" and aria-checked attributes. The included JavaScript keeps the aria state in sync with the visual state so screen readers announce it correctly.

The visual toggling works as-is. To persist the state, add your own logic inside the click handler, a fetch call, a form submission, localStorage, whatever fits your setup.

Related Tailwind CSS components

More free, copy-paste Tailwind CSS components to use in your projects.