theme-switcher
v1.0.2
Published
a theme switcher tool
Downloads
3,531
Readme
Theme Switcher
Usage
Browser
<script src="//unpkg.com/theme-switcher"></script>
<script>
var themeSwitcher = window.ThemeSwitcher({
themeMap: {
dark: '/dark.css',
default: '/default.css',
}
});
// => will load <link rel="prefetch" href="dark.css" />
// => will load <link rel="prefetch" href="default.css" />
themeSwitcher.switcher({
theme: 'dark',
});
// => will load <link rel="stylesheet" href="dark.css">
console.log(themeSwitcher.getTheme()); // => dark
</script>
ES Module
import themeSwitcher from 'theme-switcher';
const { switcher, getTheme } = themeSwitcher({
themeMap: {
dark: '/dark.css',
light: '/default.css',
}
});
// => will load <link rel="prefetch" href="dark.css" />
// => will load <link rel="prefetch" href="default.css" />
themeSwitcher.switcher({
theme: 'dark',
});
// => will load <link rel="stylesheet" href="dark.css">
console.log(themeSwitcher.getTheme()); // => dark