0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/docs/public/theme.js
2021-07-15 14:13:35 -04:00

12 lines
300 B
JavaScript

(() => {
const root = document.documentElement;
if (
localStorage.theme === 'dark' ||
(!('theme' in localStorage) &&
window.matchMedia('(prefers-color-scheme: dark)').matches)
) {
root.classList.add('theme-dark');
} else {
root.classList.remove('theme-dark');
}
})();