Meet
10/15/2026, 8:40 AMcompose-html = "1.10.0"
compose-runtime = "1.10.2"
kobweb = "0.24.0"
kotlin = "2.3.10"David Herman
10/15/2026, 6:15 PMDavid Herman
10/15/2026, 6:16 PMMeet
10/16/2026, 2:09 AMMeet
10/16/2026, 2:10 AMMeet
10/16/2026, 2:11 AMMeet
10/16/2026, 2:12 AMMeet
10/16/2026, 2:12 AMLetter
10/16/2026, 5:25 AMMeet
10/16/2026, 5:25 AMMeet
10/16/2026, 5:25 AMMeet
10/16/2026, 5:47 AMMeet
10/16/2026, 5:49 AMMeet
10/16/2026, 5:51 AMMeet
10/16/2026, 5:53 AMDavid Herman
10/16/2026, 5:56 AMDavid Herman
10/16/2026, 5:57 AMDavid Herman
10/16/2026, 5:57 AMMeet
10/16/2026, 5:57 AMMeet
10/16/2026, 6:03 AMMeet
10/16/2026, 6:03 AMDavid Herman
10/16/2026, 6:47 PMDavid Herman
10/16/2026, 6:48 PMMeet
10/17/2026, 4:27 AMChristiano
10/19/2026, 8:23 AM@InitSilk, which is also in the example kobweb project.
val colorMode = ColorMode.loadFromLocalStorage(COLOR_MODE_KEY) ?: ColorMode.systemPreference
ctx.config.initialColorMode = colorMode
// Script which runs at load time that needs to be kept in sync with `initialColorMode` above. This code checks
// if the user's local color mode preference is different from what was exported by Kobweb, replacing it if
// different to prevent a flash of color after the page loads.
if (SiteGlobals.isExporting) {
val node = document.createElement("script").apply {
textContent = """
{
const storedColor = localStorage.getItem('${COLOR_MODE_KEY}'); // 'LIGHT', 'DARK', or null
const desiredColor = storedColor ? `silk-${'$'}{storedColor.toLowerCase()}` : 'silk-dark';
const oppositeColor = desiredColor === 'silk-dark' ? 'silk-light' : 'silk-dark';
document.documentElement.classList.replace(oppositeColor, desiredColor);
}
""".trimIndent()
}
document.head?.appendChild(node)
}
Also make sure to use the CSS variables to set colors (for example BackgroundColorVar). I noticed a flicker when using just ColorMode.current.toPalette().background or something like that.Christiano
10/19/2026, 8:25 AMDavid Herman
10/19/2026, 4:18 PM