Something went wrong. Try again.
A monorepo for writing specs and other serious text on the AT Protocol.
Something went wrong. Try again.
12345678910111213// A switch: an on/off control that reads as one (a track and a knob with// its name beside it), for a mode the writer turns on and off — suggesting,// say — rather than a button that happens to be pressed.import { html } from 'lit';
/** A switch with role="switch"; `title` is its tooltip (the name and the shortcut, say). */export function renderSwitch(label: string, on: boolean, toggle: () => void, { title, cls = '' }: { title?: string; cls?: string } = {}) { return html`<button type="button" role="switch" aria-checked=${on ? 'true' : 'false'} class="draft-switch ${cls}" title=${title ?? label} @click=${toggle}> <span class="switch-track" aria-hidden="true"><span class="switch-knob"></span></span> <span class="switch-text">${label}</span> </button>`;}