Kern 0.12.0 GitHub
Fundamentals

Theming

Dark is the default; light overrides colours and shadows only. The theme is a data-theme attribute on <html>.

Switching

The toggle remembers the choice in localStorage['kern-theme'].
import { setTheme, getTheme, initTheme } from '@yfridelance/kern'; initTheme({ default: 'system' }); // 'dark' | 'light' | 'system' setTheme('light'); document.addEventListener('kernThemeChange', (e) => console.log(e.detail.theme));

Before the first paint

Set the attribute in an inline script in <head>, before the stylesheet, so the page never flashes in the wrong theme:

<script>try{document.documentElement.dataset.theme=localStorage.getItem('kern-theme')==='light'?'light':'dark'}catch(e){document.documentElement.dataset.theme='dark'}</script>

Rules