MCPcopy Create free account
hub / github.com/TryCatchLearn/Overflow / ThemeToggle

Function ThemeToggle

webapp/src/components/nav/ThemeToggle.tsx:8–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6import {useEffect, useState} from "react";
7
8export default function ThemeToggle() {
9 const {theme, setTheme} = useTheme();
10 const [mounted, setMounted] = useState(false);
11
12 useEffect(() => {
13 // eslint-disable-next-line react-hooks/set-state-in-effect
14 setMounted(true);
15 }, []);
16
17 if (!mounted) return null;
18
19 return (
20 <Button
21 color='primary'
22 variant='light'
23 isIconOnly
24 aria-label='Toggle Theme'
25 onPress={() => setTheme(theme === 'light' ? 'dark' : 'light')}
26 >
27 {theme === 'light' ? (
28 <MoonIcon className='h-8' />
29 ) : (
30 <SunIcon className='h-8 text-yellow-300' />
31 )}
32 </Button>
33 );
34}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…