MCPcopy Create free account
hub / github.com/triggerdotdev/jsonhero-web / ThemeModeToggler

Function ThemeModeToggler

app/components/ThemeModeToggle.tsx:6–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import { useTheme } from "./ThemeProvider";
5
6export function ThemeModeToggler() {
7 const [theme, setTheme] = useTheme();
8
9 const toggleTheme = () => {
10 setTheme((prevTheme) => (prevTheme === "light" ? "dark" : "light"));
11 };
12 const SwitchIcon = theme === "light" ? MoonIcon : SunIcon;
13
14 useHotkeys("alt+t", () => toggleTheme(), [toggleTheme]);
15
16 return (
17 <button
18 className={`flex text-xl items-center px-2 py-1.5 transition ${
19 theme === "light"
20 ? "text-slate-800 hover:bg-slate-300"
21 : "text-white hover:bg-slate-700"
22 }`}
23 onClick={toggleTheme}
24 >
25 <SwitchIcon />
26 </button>
27 );
28}

Callers

nothing calls this directly

Calls 2

useThemeFunction · 0.90
toggleThemeFunction · 0.85

Tested by

no test coverage detected