import { ThemeScript } from "@pixxl-tools/components";
// In Server Components:
import { ThemeScript } from "@pixxl-tools/components/server";| Prop | Type | Default | Description |
|---|---|---|---|
accent | string | — | Accent preset applied as data-accent when nothing is stored. |
storageKey | string | — | localStorage key holding the theme preference. |
accentStorageKey | string | false | — | localStorage key holding a persisted accent preset; false (or omitted) reads none. |
attribute | string | — | Extra attribute mirroring the resolved theme for your own CSS: "class" toggles light/dark classes; any other name is set to the resolved theme. data-theme is always written for Pixxl. |
cookieDomain | CookieDomainOption | — | Domain of the theme cookie a migrateFrom entry writes (a host name, or { shared } as on SitePreferencesProvider). Default: host-only. |
cookieName | string | false | storageKey | Cookie holding the theme (default: storageKey); false reads localStorage only. When the cookie holds a valid preference it wins over localStorage and is copied there: the cookie is the one store a Domain can share across subdomains, so a choice made on another site applies on the next page load here. |
defaultTheme | ThemePreference | system | Theme used when nothing is stored. Defaults to system. |
density | "comfortable" | "compact" | — | Applied as data-density when nothing is stored. |
densityStorageKey | string | false | — | localStorage key holding a persisted density (comfortable/compact); false (or omitted) reads none. |
migrateFrom | readonly ThemeMigration[] | — | Preferences stored under older keys, moved once before first paint: for each entry the old value (localStorage, then a cookie of that name) is passed through map (unmapped values are dropped), written as the new preference unless one is already stored (a newer choice wins), and the old localStorage item and cookie (host-only and on cookieDomain) are deleted, so it runs once per browser. See ThemeMigration. |
nonce | string | — | CSP nonce for nonce-based script-src policies. |
themeColor | false | ThemeColors | — | Browser UI colour (<meta name="theme-color">) for an explicit Light or Dark choice. By default the colour comes from the page's own theme-color metas with a prefers-color-scheme media query (what Next's viewport.themeColor renders): choosing Dark under a light OS adds a first <meta name="theme-color"> with the dark colour, and System removes it again. Pass { light, dark } to set the colours, or false to leave theme-color alone. |
accentstring
Accent preset applied as data-accent when nothing is stored.
storageKeystring
localStorage key holding the theme preference.
accentStorageKeystring | false
localStorage key holding a persisted accent preset; false (or omitted) reads none.
attributestring
Extra attribute mirroring the resolved theme for your own CSS: "class" toggles light/dark classes; any other name is set to the resolved theme. data-theme is always written for Pixxl.
cookieDomainCookieDomainOption
Domain of the theme cookie a migrateFrom entry writes (a host name, or { shared } as on SitePreferencesProvider). Default: host-only.
cookieNamedefault storageKeystring | false
Cookie holding the theme (default: storageKey); false reads localStorage only. When the cookie holds a valid preference it wins over localStorage and is copied there: the cookie is the one store a Domain can share across subdomains, so a choice made on another site applies on the next page load here.
defaultThemedefault systemThemePreference
Theme used when nothing is stored. Defaults to system.
density"comfortable" | "compact"
Applied as data-density when nothing is stored.
densityStorageKeystring | false
localStorage key holding a persisted density (comfortable/compact); false (or omitted) reads none.
migrateFromreadonly ThemeMigration[]
Preferences stored under older keys, moved once before first paint: for each entry the old value (localStorage, then a cookie of that name) is passed through map (unmapped values are dropped), written as the new preference unless one is already stored (a newer choice wins), and the old localStorage item and cookie (host-only and on cookieDomain) are deleted, so it runs once per browser. See ThemeMigration.
noncestring
CSP nonce for nonce-based script-src policies.
themeColorfalse | ThemeColors
Browser UI colour (<meta name="theme-color">) for an explicit Light or Dark choice. By default the colour comes from the page's own theme-color metas with a prefers-color-scheme media query (what Next's viewport.themeColor renders): choosing Dark under a light OS adds a first <meta name="theme-color"> with the dark colour, and System removes it again. Pass { light, dark } to set the colours, or false to leave theme-color alone.
<ThemeScript accent="teal" storageKey="theme" />