chat-ui_test / src /lib /switchTheme.ts
victor's picture
victor HF staff
Manifest update (#513)
7173f4f unverified
raw
history blame
474 Bytes
export function switchTheme() {
const { classList } = document.querySelector("html") as HTMLElement;
const metaTheme = document.querySelector('meta[name="theme-color"]') as HTMLMetaElement;
if (classList.contains("dark")) {
classList.remove("dark");
metaTheme.setAttribute("content", "rgb(249, 250, 251)");
localStorage.theme = "light";
} else {
classList.add("dark");
metaTheme.setAttribute("content", "rgb(26, 36, 50)");
localStorage.theme = "dark";
}
}