JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q48757F
  • License MIT

React hook to switch between light and dark themes

Package Exports

  • @vezham/use-theme
  • @vezham/use-theme/package.json

Readme

@vezham/use-theme

React hook to switch between light and dark themes

Installation

yarn add @vezham/use-theme
# or
npm i @vezham/use-theme

Usage

Import useTheme

import {useTheme} from "@vezham/use-theme";

theme

// `theme` is the active theme name
// by default, it will use the one in localStorage.
// if it is no such value in localStorage, `light` theme will be used
const {theme} = useTheme();

setTheme

You can use any theme name you want, but make sure it exists in your tailwind.config.js file. See Create Theme for more details.

// set `theme` by using `setTheme`
const {setTheme} = useTheme();
// setting to light theme
setTheme('light')
// setting to dark theme
setTheme('dark')
// setting to purple-dark theme
setTheme('purple-dark')

Contribution

Yes please! See the contributing guidelines for details.

License

This project is licensed under the terms of the MIT license.