#Get the current color scheme in JavaScript

9 messages · Page 1 of 1 (latest)

raw galleon
#

How to inline style a component based on the current color scheme? #theme #color

keen oriole
abstract folio
abstract folio
#
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}
/>
abstract folio
#

Although even putting it in the same folder doesn't make it work