Last active
April 8, 2022 16:59
-
-
Save celeroncoder/0db4e5310b8ec4e93c5c85b0a71e9cab to your computer and use it in GitHub Desktop.
Mantine Setup App Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
MantineProvider, | |
ColorScheme, | |
ColorSchemeProvider, | |
} from "@mantine/core"; | |
import { useHotkeys, useLocalStorage, useColorScheme } from "@mantine/hooks"; | |
import MainComponent from "./MainComponent"; | |
function App() { | |
const preferredColorScheme = useColorScheme(); | |
const [colorScheme, setColorScheme] = useLocalStorage<ColorScheme>({ | |
key: "mantine-color-scheme", | |
defaultValue: preferredColorScheme, | |
}); | |
const toggleColorScheme = (value?: ColorScheme) => | |
setColorScheme(value || (colorScheme === "dark" ? "light" : "dark")); | |
useHotkeys([["mod+J", () => toggleColorScheme()]]); | |
return ( | |
<ColorSchemeProvider | |
colorScheme={colorScheme} | |
toggleColorScheme={toggleColorScheme} | |
> | |
<MantineProvider theme={{ colorScheme }}> | |
<MainComponent /> | |
</MantineProvider> | |
</ColorSchemeProvider> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment