MCPcopy Create free account
hub / github.com/adobe/react-spectrum / ThemeSwitcher

Function ThemeSwitcher

examples/rac-spectrum-tailwind/src/ThemeSwitcher.js:5–17  ·  view source on GitHub ↗
({setColorScheme})

Source from the content-addressed store, hash-verified

3import Light from '@spectrum-icons/workflow/Light';
4
5export default function ThemeSwitcher({setColorScheme}) {
6 let {colorScheme} = useProvider();
7 let label = colorScheme === 'dark' ? 'Switch to light theme' : 'Switch to dark theme';
8 let otherScheme = colorScheme === 'light' ? 'dark' : 'light';
9
10 return (
11 <div className="absolute right-0 m-50">
12 <ActionButton aria-label={label} onPress={() => setColorScheme(otherScheme)}>
13 {colorScheme === 'dark' ? <Light /> : <Moon />}
14 </ActionButton>
15 </div>
16 );
17}

Callers

nothing calls this directly

Calls 2

useProviderFunction · 0.90
setColorSchemeFunction · 0.50

Tested by

no test coverage detected