omverse-ui supports dark mode via CSS media query or a class-based toggle — no extra config required.
All omverse-ui colors are CSS custom properties, so dark mode is a matter of overriding those variables. There are two standard approaches — choose whichever fits your app.
Option 1 — System preference (media query)
Override tokens inside a prefers-color-scheme: dark media query. The browser switches automatically based on the OS setting — no JavaScript needed.
index.css
tsx
1/* Automatically follow the OS preference */
2@media (prefers-color-scheme: dark) {
3 :root {
4--color-background: #0A0A0F;
5--color-surface: #111118;
6--color-surface-variant: #1A1A24;
7--color-text-primary: #F1F5F9;
8--color-text-secondary: #94A3B8;
9--color-text-tertiary: #64748B;
10--color-outline: #334155;
11--color-outline-variant: #1E293B;
12 }
13}
Option 2 — Class-based toggle
Scope overrides to a .dark class on <html>. This lets you toggle dark mode programmatically and persist the user's preference.
index.css
tsx
1/* Class-based — toggle .dark on <html> */
2.dark {
3--color-background: #0A0A0F;
4--color-surface: #111118;
5--color-surface-variant: #1A1A24;
6--color-text-primary: #F1F5F9;
7--color-text-secondary: #94A3B8;
8--color-text-tertiary: #64748B;
9--color-outline: #334155;
10--color-outline-variant: #1E293B;
11}
Use a small hook to toggle the class and save the preference to localStorage:
10 localStorage.setItem('theme', dark ? 'dark' : 'light')
11 }, [dark])
12
13return [dark, setDark] asconst
14}
Preventing flash of wrong theme
When using class-based dark mode, the page can briefly flash the wrong theme before JavaScript runs. Fix this by injecting an inline script in <head> that reads localStorage and applies the class synchronously.
The script must be inline (not a deferred or async script) so it runs before the browser paints anything.
Standalone anti-flash snippet
index.html / _document.tsx
tsx
1// Prevent flash of wrong theme — add to <head> before JS loads