Skip to main content

Toggle

A switch for toggling a boolean setting. Uses <input type="checkbox" role="switch"> โ€” styled as a pill by @primus/ui-core.

Preview ยท Toggle

Codeโ€‹

<div class="vstack" style="max-width:280px">
<label><input type="checkbox" role="switch" /> Enable notifications</label>
<label><input type="checkbox" role="switch" checked /> Dark mode</label>
<label><input type="checkbox" role="switch" disabled /> Read-only setting</label>
</div>

Propsโ€‹

PropTypeDefaultDescription
labelstring''Label text
checkedbooleanfalseChecked state
disabledbooleanfalseDisabled
sizesm | md | lgmdSize

Accessibilityโ€‹

  • Uses <input type="checkbox" role="switch"> โ€” screen readers announce "On" / "Off"
  • Keyboard: Space to toggle
  • Always provide a visible <label> โ€” do not rely on position alone
  • Use aria-label on icon-only toggles
Version history

See the Changelog for version history and breaking changes.