Skip to content

detectHostTheme

function detectHostTheme(root?, body?): ResolvedTheme;

Defined in: src/ui/theme.ts:164

The host page’s theme, for theme="inherit": an explicit signal on <html> (then <body>) — a dark/light class, a data-theme/data-mode/data-color-scheme attribute, or an inline color-scheme — and, only when the host sets none, the OS prefers-color-scheme.

Pass root/body to read other elements (tests, iframes); they default to the document’s.

Parameter Type
root? | ThemeSignalSource | null | undefined
body? | ThemeSignalSource | null | undefined

ResolvedTheme