Toggle between light and dark mode โ your preference is saved and remembered across visits. Try the switch below or use the one in the header.
Cards, text, borders, and backgrounds all respond to your mode preference. The brand colours stay constant โ only the backgrounds and text shift.
Three steps. Copy the CSS variables, add the toggle button to the header, and include the JS snippet before closing </body>.
Replace hardcoded colour values with CSS variables, then add the [data-theme="dark"] overrides block to your stylesheet.
Drop the .theme-toggle button component into your site header next to the nav links.
The script reads/saves preference to localStorage and applies it on page load โ so the user's choice persists across all pages and visits.
// Dark mode toggle โ JVDesignStudio // Persists preference via localStorage function toggleTheme() { const html = document.documentElement; const isDark = html.dataset.theme === 'dark'; html.dataset.theme = isDark ? 'light' : 'dark'; localStorage.setItem('jvds-theme', html.dataset.theme); updateLabels(); } function updateLabels() { const dark = document.documentElement.dataset.theme === 'dark'; const label = document.getElementById('modeLabel'); if (label) label.textContent = dark ? 'Dark Mode' : 'Light Mode'; } // Apply saved preference on load (function() { const saved = localStorage.getItem('jvds-theme'); const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; const theme = saved || (prefersDark ? 'dark' : 'light'); document.documentElement.dataset.theme = theme; updateLabels(); })();
The JS and CSS in this file can be copied into any JVDesignStudio page. All CSS variables are already defined above.
๐ฆ Back to Content Hub โ