Dark Mode in 5 Minutes with salt-theme-gen (No Flash, Zero Extra Dependencies) (opens in new tab)
The flash of wrong theme on page load is one of the most annoying unsolved problems in web development. You store the user's preference in localStorage, but JavaScript runs after the HTML and CSS, so there's a brief moment where the page renders in the wrong theme. This article shows the complete pattern: generate both themes, inject CSS variables, and prevent the flash with a synchronous inline script. The whole setup takes under 5 minutes. Generate both themes in one call import { generateT...
Read the original article