theme-bootstrap.ts#
5 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
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
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