Dark mode
Dark mode is a colour theme with light text on a dark background, chosen in the operating system or in the app, which a web page reads through `prefers-color-scheme`. Done well it is a second set of values for the same colour roles, not an inverted page. Meadowstack's apps follow the system setting, may let people override it, and test contrast in both themes.
By Bohuslav PoláčekChecked
* The first-paint theme script, kept free of React so a Vite config (or any
* HTML template) can inline it into <head>. It runs before the page paints,
* so a dark-mode user never sees a white flash.
*
* Logic, mirrored by resolveTheme() in theme.tsx: a stored "light" or "dark"
* wins; anything else follows prefers-color-scheme. Storage access is wrapped
* in try/catch because private windows and blocked site data throw.
*/
export const THEME_STORAGE_KEY = "kit-theme";
export const themeScript = `(function(){var p;try{p=localStorage.getItem("${THEME_STORAGE_KEY}")}catch(e){}var d=p==="dark"||(p!=="light"&&window.matchMedia("(prefers-color-scheme: dark)").matches);var r=document.documentElement;r.classList.toggle("dark",d);r.style.colorScheme=d?"dark":"light"})();`;Why it matters in a business app
People who run a dispatch board into the evening or sit in a dim warehouse office set their system to dark and expect their tools to follow. An app that stays white, or flashes white for a moment on every load, stands out in the worst way.
Dark mode is also where colour mistakes surface: a grey that reads on white sinks into a dark page, a status colour tuned for light turns muddy. If only the light theme is checked, the dark one ships broken.
How Meadowstack handles it
- Follow the system. AGENTS.md: the theme follows the system everywhere; apps may offer an override (
ThemeProvider). Never default to dark, never read the clock. - No flash.
themeScriptruns in the page's head before it paints: a stored "light" or "dark" wins, anything else followsprefers-color-scheme. Storage access is wrapped, because private windows can refuse it. - Same roles, other values. The palette generator writes the dark set from the same rules as the light one, from a dark page of
oklch(0.155 0 0), so components ask for semantic tokens and never for a theme. - Tested in both.
npm run check:contrastchecks every text and surface pair in light and dark, the end-to-end tests run axe in both, and the definition of done asks for screenshots of changed screens in light and dark.
Common mistakes
- Inverting colours. Inverted images, avatars and charts look wrong; dark mode is a palette, not a filter.
- Pure black with pure white text. The kit's dark page is a very dark grey, and its text levels are generated to hold contrast without glaring.
- Shadows that disappear. On a dark page a light shadow does nothing; the kit's dark elevation adds a faint top highlight and deeper shadows.
- Forgetting the first paint. Applying the theme after the app loads gives a white flash on every visit.
Sources
- MDN, prefers-color-schemeChecked
Questions
Should a business app default to dark mode?
No. Follow the person's system setting, which is light unless they chose otherwise, and let them override it in the app if they want.
How do you avoid the white flash when a dark page loads?
Decide the theme in a small script in the page's head, before the first paint, and set the dark class and the colour scheme there. Meadowstack's kit ships that script as themeScript.
Does dark mode need its own contrast check?
Yes. Every text and background pair has different values in dark mode, so it has to be measured again; Meadowstack's contrast guard and accessibility tests run in both themes.
Two ways
Build it yourself, or have it built
Build it yourself
Build your app on the framework
Get the codebase these apps stand on and build yours with Claude Code, Cursor or Codex.
One payment, lifetime updates
Get the frameworkHave it built
Have us build your app
Tell us how your team works. We plan the app with you and build it on the same framework at a fixed price.
After launch, Care keeps it improving, from €99 a month.
from €1,990
Describe your app