@bkbaalkrshna/switch-theme

Easily handle themes in your website


Keywords
javascript, css, theme, dark-theme, hactoberfest, js, light-theme, lightweight, switch-theme-js
License
LGPL-2.1-only
Install
npm install @bkbaalkrshna/switch-theme@0.1.3

Documentation

BK Switch Theme JS

Easily switch themes in your website

gif

GitHub stars GitHub forks GitHub issues GitHub repo size Lines of code Contributor Covenant Join the chat at https://gitter.im/BaalKrshna/switch-theme FOSSA Status

Features

  • Themes switch without page reload
  • Quick debugging
  • Add your own themes and some themes ready-made in themes folder
  • Minified version of index.js automatically available in index.min.js
  • And many more features coming

v0

If you are looking for help with v0, you should head to the main branch. This branch is developing code for v1 release.

Docs

See docs folder.

Live demo

See live demo

Click on "Dark theme" at the bottom, refresh the page, you see the page is default now set to dark theme.

FAQs

These are the frequently asked questions:

1. What happens actually

This is a basic JS code, that stores the theme name in a cookie that stays for 10 days and adds the theme name to the data-theme attribute of the html tag.

2. How to design a theme?

You need to know CSS for that.

  1. Think of a cool theme name
  2. To select the theme in CSS, use [data-theme="themeName"] where themeName is your theme name. And design styles for the theme by selecting it.
  3. To add a button for user to switch the theme (use the html a tag e.g. <a href="javascript:SwitchThemeJS.switch('dark');">Dark theme</a>)
  4. Add onload="SwitchThemeJS.get();" to your body tag
  5. Add <script async defer src="https://cdn.jsdelivr.net/gh/PuneetGopinath/switch-theme-js@v1-dev/src/index.min.js"></script> in the head tag.
  6. Set a default theme by adding data-theme attribute to html tag, with your default theme name as value
  7. That's all, test it out in your website, or submit a bug report for us to Analyse the bug.

Contributing

You can find the contributing guidelines here

Changelog

See CHANGELOG.md

Supporters

👏 A big thank you goes to all the supporters of this project!

You prove that the switch-theme-js Action has some value for you!

Stargazers

Stargazers for @PuneetGopinath/switch-theme-js

Contributors

Thanks to all contributors again!

GitHub Contributors Image

License

FOSSA Status