Didn't you try localStorage() to make dark mode persist?
When the
page loads, check the theme is set to dark. Then it applies the dark mode.
`let trilho = document.getElementById('trilho');
let body = document.querySelector('body');
const theme = localStorage.getItem("theme");
if (theme === "dark") {
trilho.classList.add("dark");
body.classList.add("dark");
}
Every time when the user toggles the button, check the body has dark class. If it does save it on the localStorage,
trilho.addEventListener('click', () => { trilho.classList.toggle('dark'); body.classList.toggle('dark');
if (body.classList.contains("dark")) {
localStorage.setItem("theme", "dark");
} else {
localStorage.setItem("theme", "light");
}
});