Files
Homarr/components/ColorSchemeToggle/ColorSchemeToggle.tsx

29 lines
792 B
TypeScript
Raw Normal View History

2022-04-25 00:11:32 +02:00
import { ActionIcon, useMantineColorScheme } from '@mantine/core';
import { Sun, MoonStars } from 'tabler-icons-react';
import { motion } from 'framer-motion';
2022-04-24 22:36:47 +02:00
export function ColorSchemeToggle() {
const { colorScheme, toggleColorScheme } = useMantineColorScheme();
return (
2022-04-25 00:11:32 +02:00
<motion.div
whileHover={{ scale: 1.2, rotate: 90 }}
whileTap={{
scale: 0.8,
rotate: -90,
borderRadius: '100%',
}}
>
2022-04-24 22:36:47 +02:00
<ActionIcon
onClick={() => toggleColorScheme()}
size="xl"
sx={(theme) => ({
color: theme.colorScheme === 'dark' ? theme.colors.yellow[4] : theme.colors.blue[6],
})}
>
2022-04-25 00:11:32 +02:00
{colorScheme === 'dark' ? <Sun size={24} /> : <MoonStars size={24} />}
2022-04-24 22:36:47 +02:00
</ActionIcon>
2022-04-25 00:11:32 +02:00
</motion.div>
2022-04-24 22:36:47 +02:00
);
}