Design comparison
SolutionDesign
Solution retrospective
What challenges did you encounter, and how did you overcome them?
What has been most difficult for me has been making Tailwind change the background color of the screen between dark and light. In the end I solved it with the following code
const [isDarkMode, setIsDarkMode] = useState(false);
useEffect(() => { if (isDarkMode) { document.body.classList.add("dark", "bg-Very-Dark-Blue"); document.body.classList.remove("bg-white"); } else { document.body.classList.remove("dark", "bg-Very-Dark-Blue"); document.body.classList.add("bg-white"); } }, [isDarkMode]);
const toggleDarkMode = () => { setIsDarkMode(!isDarkMode); };
Community feedback
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord