# gatsby-plugin-themes

> Gatsby plugin for defining multiple themes, and switch between them.

Latest version **0.3.9** (published 2019-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install gatsby-plugin-themes
pnpm add gatsby-plugin-themes
yarn add gatsby-plugin-themes
bun add gatsby-plugin-themes
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.9 |
| Published | 2019-10-31 |
| First published | 2019-08-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 0 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Xiaoxing Hu |
| Maintainers | xiaoxinghu |
| Keywords | gatsby, gatsby-plugin, theme, context |

## Links

- npm: https://www.npmjs.com/package/gatsby-plugin-themes
- Repository: https://github.com/xiaoxinghu/gatsby-plugin-themes
- Homepage: https://github.com/xiaoxinghu/gatsby-plugin-themes/blob/master/README.md
- Issues: https://github.com/xiaoxinghu/gatsby-plugin-themes/issues
- npm.io page: https://npm.io/package/gatsby-plugin-themes

## Recent versions

- 0.3.9 (latest) — 2019-10-31
- 0.3.8 — 2019-10-25
- 0.3.7 — 2019-10-25
- 0.3.6 — 2019-10-25
- 0.3.5 — 2019-10-25
- 0.3.4 — 2019-10-25
- 0.3.1 — 2019-10-25
- 0.3.0 — 2019-10-25
- 0.2.1 — 2019-08-25
- 0.2.0 — 2019-08-23
- 0.1.0 — 2019-08-22

## README

# gatsby plugin for themes (and switching between them)

This is a style system agnostic plugin. No matter what style system you are
using (styled-components, emotion, theme-ui ...), you can use them with this
plugin.

# How to Use

In your `gatsby-config.js` file.
``` javascript
module.exports = {
  // ...
  {
    resolve: `gatsby-plugin-themes`,
    options: {
      themes: [
        `${__dirname}/src/themes/dark.js`,
        `${__dirname}/src/themes/light.js`,
      ],
    },
  }
  // ...
}
```

And anywhere in any of your components.

``` javascript
import React, { useContext } from 'react'
import { ThemeContext } from 'gatsby-plugin-themes'
// ...
const { theme, next } = useContext(ThemeContext)
```

Here the `theme` is one of your modules decleared in the `gatsby-config.js` file
(in this example, `dark.js` or `light.js`). And I don't care what's in it, nor
how you use it, you are the boss.

The `next` is a function to toggle between your themes. And that's about it. Enjoy.

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