react-perfect-dark-mode
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

react-perfect-dark-mode

Version Size

Installation

You must first install perfect-dark-mode into the <head> of your document.

yarn add react-perfect-dark-mode

Usage

In a component you can use the hook:

import React from 'react'
import { usePerfectDarkMode } from 'react-perfect-dark-mode'

export const Toggle = () => {
  const { mode, updateMode } = usePerfectDarkMode()
  return (
    <button
      style={{ visibility: mode !== undefined ? 'visible' : 'hidden' }}
      onClick={() =>
        updateMode(
          (mode, modes, modeIndex) => modes[(modeIndex + 1) % modes.length],
        )
      }
    >
      {mode}
    </button>
  )
}

Readme

Keywords

Package Sidebar

Install

npm i react-perfect-dark-mode

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

3.19 kB

Total Files

4

Last publish

Collaborators

  • dylanvann