Skip to content

Latest commit

Β 

History

History
27 lines (20 loc) Β· 462 Bytes

useDarkMode.md

File metadata and controls

27 lines (20 loc) Β· 462 Bytes

🍩 useDarkMode

Toggles (and saves to localStorage) dark mode

Returns

  • darkMode: Bool: true when dark.
  • setDarkMode: Function(): Toggles darkMode

Usage

import { useDarkMode } from "react-recipes";

function App() {
  const [darkMode, setDarkMode] = useDarkMode();

  return (
    <div>
      <div className="navbar">
        <Toggle darkMode={darkMode} setDarkMode={setDarkMode} />
      </div>
      <Content />
    </div>
  );
}