simple-theme-manager
v1.1.4
Published
A very lightweight npm package that allows you to quickly switch the dark theme
Downloads
9
Readme
:dart: Features
- Light weight
- System theme support
- Toggles document attribute
- Freedom in css
- Saving to localStorage
- Easy to use
- Any framework
:toolbox: Getting Started
:bangbang: Prerequisites
- Install Node JS in your computer Here
:gear: Installation
In your terminal
npm i simple-theme-manager
In your main.js
import theme_manager from "simple-theme-manager"; // Import a module
window.theme_manager = theme_manager; // Connect the module to global access
On created app or in main.js
theme_manager.init(); // Let's launch the module. If the theme is saved, it is applied. Otherwise, run in auto mode
✍️ Using
Apply theme In auto mode, you can change the theme on your device, and it will also change in the application.
theme_manager.apply("auto" || "light" || "dark"); // One of three modes is applied - auto, light or dark
Get current theme mode
theme_manager.getMode(); // Returns auto | light | dark
Get current theme
theme_manager.getTheme(); // Returns light | dark (even in auto mode)
Reset settings
theme_manager.reset(); // Deletes data from localStorage and applies auto mode