<theme-switch>

An accessible on/off switch built with Lit on top of a native checkbox. Works with the keyboard, too.

Try it

Dark theme for this page
Custom colours
Disabled

Flip the first switch…

Use it

npm install @firstprateek/switch
// main.js
import '@firstprateek/switch';

document.querySelector('theme-switch')
  .addEventListener('change', (e) => console.log(e.detail.checked));

<!-- index.html -->
<theme-switch label="Dark theme"></theme-switch>