#Get the current color scheme in JavaScript
9 messages · Page 1 of 1 (latest)
document.documentElement.getAttribute('data-mantine-color-scheme')
There was a useMantineTheme hook, I am looking for it, this one doesn't work here...
I want to change the log variant (png file) dynamically based on dark or light, how to do that?
Why it does not work?
I am not sure, take a look at the code...
import lightLogo from "/Logo.png";
import darkLogo from "/Logo-dark.png"; // stored in public folder at root level
----------------------------
useEffect(() => {
const theme = document.documentElement.getAttribute('data-mantine-color-scheme');
setLogoSrc(theme === 'dark' ? darkLogo : lightLogo);
}, []);
const [logoSrc, setLogoSrc] = useState(lightLogo);
<Image
radius="md"
src={logoSrc}
/>
I think it's related somehow to the import statement where the logos are in the public folder, or is this the way we do it in react?
Although even putting it in the same folder doesn't make it work