Hi all, i have a button that toggles the dark/light theme, i also have some custom colors in the theme.ts file. However, I cant get the custom dark color to show in the App, but not the custom light color.
wrapping the app:
import { theme } from "./theme";
...
<MantineProvider theme={theme}>
<Router />
</MantineProvider>
...
on click togggle theme calls:
import cx from "clsx";
import {
useMantineColorScheme,
useComputedColorScheme,
Group,
} from "@mantine/core";
// import { useMantineTheme } from '@mantine/core';
import { IconSun, IconMoon } from "@tabler/icons-react";
import classes from "./ColorSchemeToggle.module.css";
export function ColorSchemeToggle() {
const { setColorScheme } = useMantineColorScheme();
const computedColorScheme = useComputedColorScheme("light", {getInitialValueInEffect: true,});
// const theme = useMantineTheme();
return (
<Group>
<button
style={{
border: "none",
background: "none",
cursor: "pointer",
}}
onClick={() => setColorScheme(computedColorScheme === "light" ? "dark" : "light")}
>
<IconSun className={cx(classes.icon, classes.light)} stroke={1.5} />
<IconMoon className={cx(classes.icon, classes.dark)} stroke={1.5} />
</button>
</Group>
);
}
theme.ts
import { createTheme } from '@mantine/core';
export const theme = createTheme({
colors: {
'dark': [
'#d5d7e0',
'#acaebf',
'#8c8fa3',
'#fff7cc',
'#4d4f66',
'#34354a',
'#262230', // button inner (sun button in dark mode)
'#0d021c', // main #0d021c
'#0c0d21',
'#01010a',
],
'light': [
"#ffe9f3",
"#fed3e2",
"#f5a7c0",
"#ed779d",
"#e64f7f",
"#e2356c",
"#e12663",
"#c91753",
"#b30d49",
"#9f003e"
],
},
});