Skip to content
Svartz v2.6.0

@svartz/ui/color-mode

7 exported symbols.

Types

t ColorMode

Functions

f currentColorModeThe mode the page currently renders in.
f setColorModePin a mode on <html>, remember it, and tell listeners (comments, graphs).

Variables

v COLOR_MODE_KEYlocalStorage key for the reader's explicit choice. Absent means "follow the OS".
v COLOR_MODE_SCRIPTInline `<head>` script. Pins the stored mode on <html> before first paint so dark readers never see a light flash. Without a stored mode the OS decides through `color-scheme: light dark`.
v COLOR_MODE_SCRIPT_HASHCSP source for `COLOR_MODE_SCRIPT`. A host with a Content Security Policy adds it to `script-src` so the script can run; `color-mode.test.ts` keeps it in sync.
v COLOR_MODE_TAG`COLOR_MODE_SCRIPT` as a `<script>` element. It lives here rather than in `ColorModeToggle.svelte` because Vite's dependency scanner reads any `<script>` text in a `.svelte` file as the component's script and fails.