# theme-switcher

> a theme switcher tool

Latest version **1.0.2** (published 2020-01-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install theme-switcher
pnpm add theme-switcher
yarn add theme-switcher
bun add theme-switcher
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-01-02 |
| First published | 2020-01-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | ycjcl868 |
| Maintainers | chenshuai2144, ycjcl868 |

## Links

- npm: https://www.npmjs.com/package/theme-switcher
- Repository: https://github.com/ycjcl868/theme-switcher
- Homepage: https://github.com/ycjcl868/theme-switcher#readme
- Issues: https://github.com/ycjcl868/theme-switcher/issues
- npm.io page: https://npm.io/package/theme-switcher

## Recent versions

- 1.0.2 (latest) — 2020-01-02
- 1.0.1 — 2020-01-02
- 1.0.0 — 2020-01-02
- 1.0.0-beta.2 — 2020-01-02

## README

# Theme Switcher

[![codecov](https://codecov.io/gh/ycjcl868/theme-switcher/branch/master/graph/badge.svg)](https://codecov.io/gh/ycjcl868/theme-switcher) [![NPM version](https://img.shields.io/npm/v/theme-switcher.svg?style=flat)](https://npmjs.org/package/theme-switcher) [![NPM downloads](http://img.shields.io/npm/dm/theme-switcher.svg?style=flat)](https://npmjs.org/package/theme-switcher) [![CircleCI](https://circleci.com/gh/ycjcl868/theme-switcher/tree/master.svg?style=svg)](https://circleci.com/gh/ycjcl868/theme-switcher/tree/master)

## Usage

Browser

```html
<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

```js
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
```

---
_Source: https://npm.io/package/theme-switcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
