theme-bootstrap.ts#
7 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
fnapplyThemeBootstrap(options: ThemeBootstrapOptions = {}): ThemeBootstrapStateApply the resolved theme state to the configured root element. Hosts can reuse…
Apply the resolved theme state to the configured root element.
Hosts can reuse this inside applyThemeTransition({ apply }) so the initial bootstrap and later toggles share one storage/root contract.
Signature
export function applyThemeBootstrap(options: ThemeBootstrapOptions = {}): ThemeBootstrapStateParameters
-
optionsThemeBootstrapOptionsoptional · default: {}
Returns
ThemeBootstrapState
fncreateThemeBootstrapDocumentStyle(options: ThemeBootstrapOptions = {}): stringReturn the exact inline CSS body for the document colour fallback. Hash this st…
Return the exact inline CSS body for the document colour fallback.
Hash this string for CSP when a host cannot use style nonces.
Signature
export function createThemeBootstrapDocumentStyle(options: ThemeBootstrapOptions = {}): stringParameters
-
optionsThemeBootstrapOptionsoptional · default: {}
Returns
string
fncreateThemeBootstrapScript(options: ThemeBootstrapOptions = {}): stringReturn the exact inline JavaScript body a static host can hash for CSP.
Return the exact inline JavaScript body a static host can hash for CSP.
Signature
export function createThemeBootstrapScript(options: ThemeBootstrapOptions = {}): stringParameters
-
optionsThemeBootstrapOptionsoptional · default: {}
Returns
string
fnrenderThemeBootstrapDocumentColors(options: ThemeBootstrapOptions = {}, renderOptions: RenderThemeBootstrapScriptOptions = {}): stringRender the optional no-JS document colour fallback for custom hosts. Place this…
Render the optional no-JS document colour fallback for custom hosts.
Place this before the bootstrap script and app stylesheets. The script will update the emitted single theme-color meta whenever storage or toggles resolve to another theme.
Signature
export function renderThemeBootstrapDocumentColors(options: ThemeBootstrapOptions = {}, renderOptions: RenderThemeBootstrapScriptOptions = {}): stringParameters
-
optionsThemeBootstrapOptionsoptional · default: {}
-
renderOptionsRenderThemeBootstrapScriptOptionsoptional · default: {}
Returns
string
fnrenderThemeBootstrapScript(options: ThemeBootstrapOptions = {}, renderOptions: RenderThemeBootstrapScriptOptions = {}): stringRender an inline first-paint bootstrap tag. Use createThemeBootstrapScript() wh…
Render an inline first-paint bootstrap tag.
Use createThemeBootstrapScript() when a deployment needs the exact body for a CSP hash. Use nonce here when the host supplies per-request nonces.
Signature
export function renderThemeBootstrapScript(options: ThemeBootstrapOptions = {}, renderOptions: RenderThemeBootstrapScriptOptions = {}): stringParameters
-
optionsThemeBootstrapOptionsoptional · default: {}
-
renderOptionsRenderThemeBootstrapScriptOptionsoptional · default: {}
Returns
string
fnresolveThemeBootstrapState(storedPreference: string | null | undefined, prefersDark: boolean, options: ThemeBootstrapOptions = {}): ThemeBootstrapStateResolve a stored theme preference to the root state the bootstrap applies.
Resolve a stored theme preference to the root state the bootstrap applies.
Signature
export function resolveThemeBootstrapState(storedPreference: string | null | undefined, prefersDark: boolean, options: ThemeBootstrapOptions = {}): ThemeBootstrapStateParameters
-
storedPreferencestring | null | undefined -
prefersDarkboolean -
optionsThemeBootstrapOptionsoptional · default: {}
Returns
ThemeBootstrapState
fnsetThemeBootstrapPreference(preference: ThemeBootstrapPreference, options: ThemeBootstrapOptions = {}): ThemeBootstrapStatePersist a preference and apply it with the same root contract as the bootstrap.
Persist a preference and apply it with the same root contract as the bootstrap.
Signature
export function setThemeBootstrapPreference(preference: ThemeBootstrapPreference, options: ThemeBootstrapOptions = {}): ThemeBootstrapStateParameters
-
preferenceThemeBootstrapPreference -
optionsThemeBootstrapOptionsoptional · default: {}
Returns
ThemeBootstrapState