0.0.7 • Published 3 years ago

react-hook-tailwind-darkmode v0.0.7

Weekly downloads
23
License
MIT
Repository
github
Last release
3 years ago

React Hook Tailwind Darkmode

Introduction

This is a React hook changing darkmode in Tailwind CSS.

Installation

npm install -D react-hook-tailwind-darkmode

yarn add -D react-hook-tailwind-darkmode

Usage

This hook is using the function named changeTheme to change theme.

import {ReactElement} from "react";
import {useTheme} from "react-hook-tailwind-darkmode";

export function App(): ReactElement {
  const {changeTheme} = useTheme();

  return (
    <div className="bg-white dark:bg-black">
      ...
      <button onClick={() => changeTheme() type="button"}>
        change theme
      </button>
    </div>
  );
}

Tailwind CSS config

You need to use the class strategy for this hook. The config you should set is on the below.

// tailwind.config.js
module.exports = {
  darkMode: 'class',
  // ...
}

Read more details .

TODO

  • DEMO
  • TEST
  • CI

License

react-hook-tailwind-dakrmode is MIT LICENSED

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago