Toggle — Vanilla

Toggle button with vanilla HTML. Ensure Rizzo CSS is loaded.

Toggle

Button with aria-pressed. Use class toggle; add toggle--pressed when pressed (or aria-pressed="true" is styled).

Add this component

The command below includes <strong>Toggle</strong>—run it in your project directory to install this component (and the CSS if needed). No prompts.

Choose your package manager — click a tab to select, then copy the command.

npm pnpm yarn bun
Live example

Click to toggle.

HTML

html html
<button type="button" class="toggle" aria-pressed="false">Off</button>
<button type="button" class="toggle toggle--pressed" aria-pressed="true">On</button>

Other frameworks: Astro · Svelte · Vue · React