themer

About

themer was made as a part of commitlog-web. To support both system preference and manual selection by users for the base theme of an app. It bases off it's decision based on the state set by the user. If a user is visiting the site for the first time the state is set to pick the current system preference and set that as the chosen theme

If the user then decides to switch the theme using the toggle, the selected theme is set as a permanent preference for that website unless the site data is cleared from the browser.

Demo

A demo of the above can be seen both at commitlog-web and on this very site.

or you could use the below custom implementation

Usage

The library was built for vanilla javascript so it's pretty easy to use in any other framework/ui-library that you might choose to use. I'll list out the basic steps.

  • Install `@barelyreaper/themer` if using a bundler or add this to your html scripts.
  • Next, we create an instance of Themer with the trigger element passed to it to use the default icons provided by the library, (this needs feather-icons installed)
  • You can then follow the example below
  • Support

    If you do like this project, please consider supporting it.