import { Box, Center, ColorScheme, SegmentedControl, Stack, useMantineColorScheme, } from "@mantine/core"; import { useColorScheme } from "@mantine/hooks"; import { useState } from "react"; import { TbDeviceLaptop, TbMoon, TbSun } from "react-icons/tb"; import usePreferences from "../../hooks/usePreferences"; const ThemeSwitcher = () => { const preferences = usePreferences(); const [colorScheme, setColorScheme] = useState( preferences.get("colorScheme") ); const { toggleColorScheme } = useMantineColorScheme(); const systemColorScheme = useColorScheme(); return ( { preferences.set("colorScheme", value); setColorScheme(value); toggleColorScheme( value == "system" ? systemColorScheme : (value as ColorScheme) ); }} data={[ { label: (
Dark
), value: "dark", }, { label: (
Light
), value: "light", }, { label: (
System
), value: "system", }, ]} />
); }; export default ThemeSwitcher;