MCPcopy Create free account
hub / github.com/pollinations/pollinations / useColorMode

Function useColorMode

packages/ui/src/primitives/ColorModeToggle.tsx:124–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122}
123
124export function useColorMode(): {
125 mode: ColorMode;
126 isDark: boolean;
127 toggle: () => void;
128} {
129 const mode = useSyncExternalStore(
130 subscribe,
131 getSnapshot,
132 getServerSnapshot,
133 );
134 return {
135 mode,
136 isDark: mode === "dark",
137 toggle: () => setColorMode(mode === "dark" ? "light" : "dark"),
138 };
139}
140
141/**
142 * Sliding sun/moon switch. Light/dark is a two-state choice, not an on/off

Callers 3

PrimitivesPageFunction · 0.90
RootLayoutFunction · 0.90
ColorModeToggleFunction · 0.85

Calls 1

setColorModeFunction · 0.85

Tested by

no test coverage detected