Web component / esm

<theme-switcher>

Postpublication import example

This page displays source only. It doesn’t execute the import or render a live picker. After the referenced versions are published, esm.sh can bundle the base dependency:

<script type="module">
  import { ThemeSwitcherElement } from
    'https://esm.sh/@aarongustafson/theme-switcher@1.0.1/theme-switcher.js?bundle&target=es2022';
  customElements.define('theme-switcher',
    ThemeSwitcherElement);
</script>
<theme-switcher label="Color theme">
</theme-switcher>

Use the working local demos. The generated drop-in control shown here has no usable controls before upgrade or without JavaScript. You can supply radio markup instead for native selection and form submission.