Skip to content

Instantly share code, notes, and snippets.

@blainelewis1
blainelewis1 / hooks.js
Created September 11, 2020 06:21
Hook for adding dark mode to any project.
import { useEffect } from "react";
export function useDarkMode(isDarkMode = true) {
useEffect(() => {
if (isDarkMode) {
document.body.style.backgroundColor = "black";
document.body.style.filter = "invert(1) hue-rotate(180deg)";
} else {
document.body.style.backgroundColor = "white";
document.body.style.filter = "";