theme-switcher
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Theme Switcher

codecov NPM version NPM downloads CircleCI

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

Readme

Keywords

none

Package Sidebar

Install

npm i theme-switcher

Weekly Downloads

832

Version

1.0.2

License

ISC

Unpacked Size

7.08 kB

Total Files

6

Last publish

Collaborators

  • chenshuai2144
  • ycjcl868