Skip to content

mothepro/theme-toggle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

<theme-toggle>

Web Component to natively change your site's theme

npm Published on webcomponents.org

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>.