mirror of
https://github.com/tuono-labs/tuono
synced 2026-07-29 22:02:46 -07:00
31 lines
820 B
TypeScript
31 lines
820 B
TypeScript
|
|
import {
|
||
|
|
ActionIcon,
|
||
|
|
useMantineColorScheme,
|
||
|
|
useComputedColorScheme,
|
||
|
|
} from '@mantine/core'
|
||
|
|
import { IconSun, IconMoon } from '@tabler/icons-react'
|
||
|
|
import cx from 'clsx'
|
||
|
|
|
||
|
|
import classes from './theme-btn.module.css'
|
||
|
|
|
||
|
|
export default function ThemeBtn(): JSX.Element {
|
||
|
|
const { setColorScheme } = useMantineColorScheme()
|
||
|
|
const computedColorScheme = useComputedColorScheme('light', {
|
||
|
|
getInitialValueInEffect: true,
|
||
|
|
})
|
||
|
|
|
||
|
|
return (
|
||
|
|
<ActionIcon
|
||
|
|
onClick={() =>
|
||
|
|
setColorScheme(computedColorScheme === 'light' ? 'dark' : 'light')
|
||
|
|
}
|
||
|
|
variant="default"
|
||
|
|
size="lg"
|
||
|
|
aria-label="Toggle color scheme"
|
||
|
|
>
|
||
|
|
<IconSun className={cx(classes.icon, classes.light)} stroke={1.5} />
|
||
|
|
<IconMoon className={cx(classes.icon, classes.dark)} stroke={1.5} />
|
||
|
|
</ActionIcon>
|
||
|
|
)
|
||
|
|
}
|