# 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

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

## Methods

### apply

```ts
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

```ts
getSystemTheme(): ResolvedTheme;
```

The theme the operating system prefers now.

### subscribe

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

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

- `listener` (`(theme: ResolvedTheme) => void`)

## See also

- [`ResolvedTheme`](https://docs.mapcairn.com/api/core/ResolvedTheme.md)

Source: [packages/core/src/ports/theme.ts:9](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/ports/theme.ts#L9)
