Move theme configuration to ThemeProvider

This commit is contained in:
Vitaly Rtishchev 2022-11-23 11:31:23 +04:00
parent 45bee5df4f
commit f78e211143
3 changed files with 21 additions and 9 deletions

View File

@ -1,15 +1,15 @@
import { MantineProvider, Text, Button, Stack } from "@mantine/core"; import { Text, Button, Stack } from "@mantine/core";
import { theme } from "./theme"; import { ThemeProvider } from "./ThemeProvider";
export default function App() { export default function App() {
return ( return (
<MantineProvider theme={theme} withGlobalStyles withNormalizeCSS> <ThemeProvider>
<Stack align="center" mt={50}> <Stack align="center" mt={50}>
<Text size="xl" weight={500}> <Text size="xl" weight={500}>
Welcome to Mantine! Welcome to Mantine!
</Text> </Text>
<Button>Click the button</Button> <Button>Click the button</Button>
</Stack> </Stack>
</MantineProvider> </ThemeProvider>
); );
} }

17
src/ThemeProvider.tsx Normal file
View File

@ -0,0 +1,17 @@
import { MantineProvider, MantineThemeOverride } from "@mantine/core";
export const theme: MantineThemeOverride = {
colorScheme: "dark",
};
interface ThemeProviderProps {
children: React.ReactNode;
}
export function ThemeProvider({ children }: ThemeProviderProps) {
return (
<MantineProvider withGlobalStyles withNormalizeCSS theme={theme}>
{children}
</MantineProvider>
);
}

View File

@ -1,5 +0,0 @@
import { MantineThemeOverride } from "@mantine/core";
export const theme: MantineThemeOverride = {
colorScheme: "dark",
};