<theme-toggle>
Web Component to natively change your site's theme
Install
yarn add @mothepro/theme-toggle
How to Use
Attribute | Type | Default | Description |
---|---|---|---|
persistent |
boolean |
false |
Whether the theme should be saved on reload |
theme |
dark or light
|
light |
The theme to use, this attribute is added to the <body> too |
<!--
Import the element.
The `module` query parameter expands "bare" imports to full unpkg.com urls.
This means use of an import map isn't needed.
@see https://unpkg.com#query-params
-->
<script type="module" src="//unpkg.com/@mothepro/theme-toggle/dist/esm/index.js?module"></script>
Click to change theme to
<theme-toggle persistent>
<u slot="light">dark</u>
<u slot="dark">light</u>
</theme-toggle>.