s72
  • Switch

    role="switch

    A checkbox with role="switch" becomes a switch. It is a real checkbox, so it submits with the form and reads as a switch to a screen reader.

    Basic

    html
    <p style="display:grid;gap:1rem">
      <label><input type="checkbox" role="switch" checked> Rebuild on save</label>
      <label><input type="checkbox" role="switch"> Minify the output</label>
    </p>

    Clicking the label flips the switch, because the input sits inside it.

    Notes