@intility/bifrost-react
Version:
React library for Intility's design system, Bifrost.
18 lines (17 loc) • 657 B
JavaScript
"use client";
import { useLayoutEffect } from "react";
/**
* React single-page-application helper to apply a Bifrost color mode to the
* root document element.
* Avoid for Next.js or other Server-Side frameworks where you can control the
* `<html>` element directly.
* @param mode Can be one of "light", "dark", or "system".
*/ export default function useApplyColorMode(mode) {
// apply color mode class name to document
useLayoutEffect(()=>{
document.documentElement.classList.toggle("bf-lightmode", mode === "light");
document.documentElement.classList.toggle("bf-darkmode", mode === "dark");
}, [
mode
]);
}