Skip to main content

ThemeSource

The operating system's colour scheme, and the place the resolved theme is applied. The ui combines it with the stored choice through the core resolver.

This is an interface exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import type { ThemeSource } from "@mapcairn/core";

interface ThemeSource

Methods​

apply​

apply(theme: ResolvedTheme): void;

Reflects the resolved theme onto the document: the data-theme attribute, the color-scheme property and the theme-color meta tag.

  • theme (ResolvedTheme)

getSystemTheme​

getSystemTheme(): ResolvedTheme;

The theme the operating system prefers now.

subscribe​

subscribe(listener: (theme: ResolvedTheme) => void): () => void;

Calls the listener when the system preference changes. Returns the unsubscribe function.

  • listener ((theme: ResolvedTheme) => void)

See also​

Source: packages/core/src/ports/theme.ts:9