Switch web component
An example of switch controls (
role=switch) built as a web component.
I'm sure this could be better constructed, so PRs are welcome :)
If set, will display "On" and "Off" text labels in toggle UI.
If set, will default to "on / checked" state. Otherwise will default to "off / unchecked".
If set, will default to
Screen Reader Quirks
Please review the breakdown of screen reader issues with
role="switch". While this particular link goes to an example of using
role=switch on a checkbox, the same issues occur if using
role=switch on a
button element as well, as this web component does.
License & Such
This script was written by Scott O'Hara.
It has an MIT license.
Do with it what you will :)