---
title: '@svartz/ui/color-mode'
description: The `@svartz/ui/color-mode` entry point.
updated_at: '2026-10-29T02:28:30+01:00'
---

# @svartz/ui/color-mode

## Types

- [ColorMode](https://svartz.dev/reference/api/ui/color-mode/colormode.md)

## Functions

- [currentColorMode](https://svartz.dev/reference/api/ui/color-mode/currentcolormode.md) — The mode the page currently renders in.
- [setColorMode](https://svartz.dev/reference/api/ui/color-mode/setcolormode.md) — Pin a mode on <html>, remember it, and tell listeners (comments, graphs).

## Variables

- [COLOR_MODE_KEY](https://svartz.dev/reference/api/ui/color-mode/color_mode_key.md) — localStorage key for the reader's explicit choice. Absent means "follow the OS".
- [COLOR_MODE_SCRIPT](https://svartz.dev/reference/api/ui/color-mode/color_mode_script.md) — Inline `<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`.
- [COLOR_MODE_SCRIPT_HASH](https://svartz.dev/reference/api/ui/color-mode/color_mode_script_hash.md) — CSP 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.
- [COLOR_MODE_TAG](https://svartz.dev/reference/api/ui/color-mode/color_mode_tag.md) — `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.
