npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rethemes

v0.0.1

Published

Manage color themes in your React application

Downloads

0

Readme

A small, fast and accessible solution to manage your color themes in your React application. It works with a functionnal aproach letting you create your own React Context Provider and getting all you need to make it easy to create a theme picker. Based on prefers-color-scheme user's browser preferences, it helps you to add a dark mode, and/or add as many themes as you need on your app (like a colorblind theme one).

Getting Started

To get a local copy up and running follow these simple steps.

Installation

$ npm install rethemes

or using Yarn

$ yarn add rethemes

Usage

Create your theme.js file

First, import create from rethemes and use it to create your context provider: ThemeProvider, and React hook: useTheme

// theme.js
import { create } from 'rethemes'

const { ThemeProvider, useTheme } = create({
  themes: ['light', 'dark'],
  defaultTheme: 'light',
})

export {
  ThemeProvider,
  useTheme
}

Under the hood, if you specify light and dark in the themes argument, the library will sync automatically with the user's browser preferences (prefers-color-scheme).

Add the provider in your application

Next, add the provider:

// App.js
import { ThemeProvider } from './theme.js'

export function App() {
  return (
    <ThemeProvider>
      <MyApp />
    </ThemeProvider>
  )
}

Create your theme picker

Use the hook useTheme to get the active theme and the method to change active theme. useTheme returns a themes props to help you creating a theme picker.

// ThemePicker.js
import { useTheme } from './theme.js'

export function ThemePicker() {
  const { activeTheme, setActiveTheme, themes} = useTheme

  const setDarkTheme = () => {
    setActiveTheme('dark')
  }

  const setLightTheme = () => {
    setActiveTheme('light')
  }

  return (
    <div>
      <Button onClick={setDarkTheme}>Change theme to dark</Button>
      <Button onClick={setLightTheme}>Change theme to light</Button>
      <ul>
        {themes.map(theme => (
          <li key={theme.key}>
            <Button onClick={theme.setActive}>Change theme to {theme.key}</Button>
          </li>
        ))}
      </ul>
    </div>
  )
}

Add custom themes

With react-theme you can manage any themes you want. To do so, just add as many themes as you like to the themes argument of the create method

// theme.js
const { ThemeProvider, useTheme } = create({
  themes: ['light', 'dark', 'colorblind', 'high-contrast'],
  defaultTheme: 'light',
})

They wil be available on useTheme

// ThemePicker.js
const { activeTheme, setActiveTheme, themes} = useTheme

const setColorblindTheme = () => {
  setActiveTheme('colorblind')
}

const setHighContrastTheme = () => {
  setActiveTheme('high-contrast')
}

// `themes` will contains colorblind and high-contrast too

Manage CSS colors with rethemes

The library will automatically append a classlist related to the active theme to the body HTML element with the theme prefix.

You can use CSS variables to manage colors like:

 /* theme.css */
body.theme-light {
  --text-color: black;
}

body.theme-dark {
  --text-color: white;
}

body.theme-colorblind {
  --text-color: black;
}

body.theme-high-contrast {
  --text-color: purple;
}

Then use them on your CSS files:

 /* theme.css */
.block {
  color: var(--text-color);
}

API

create arguments

| Option | Type | Description | | ----------------------- | ------------------------------------------| ------------------------------------------------------------| | themes | string[] | List of themes you want to use | | defaultTheme | string | Theme you would like to use as default. | | expiryDuration | number | List of themes to map on, helping you create a theme picker |

Note: defaultTheme is Based on themes. If defaultTheme is not includes in themes it will be added.

Note 2: all strings in themes are inferred as a union type (Theme) dispatched to the context and hook (you will have the auto-completion each time you should be able to update or access to it).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Antoine Lin - @vahilloff - [email protected]

Project Link: https://github.com/toinelin/rethemes

Acknowledgements

Please feel free to open a pull request to add your project to the list!