/** * Point the stylesheet at an appearance choice. An explicit light or dark pins * the palette through the root data-theme attribute; anything else removes * the attribute so the prefers-color-scheme rules decide. * @param {string} [theme] */ export function applyTheme(theme) { const root = document.documentElement; if (theme === 'light' || theme === 'dark') { root.dataset.theme = theme; } else { delete root.dataset.theme; } }