Skip to content

theme-bootstrap.ts#

View Markdown

Source

5 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

5 symbols 5 functions 9 parameters 5 returns

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 = {}): ThemeBootstrapState

View source

Parameters

  • options ThemeBootstrapOptions

    optional · 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 = {}): string

View source

Parameters

  • options ThemeBootstrapOptions

    optional · 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 = {}): string

View source

Parameters

  • options ThemeBootstrapOptions

    optional · default: {}

  • renderOptions RenderThemeBootstrapScriptOptions

    optional · 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 = {}): ThemeBootstrapState

View source

Parameters

  • storedPreference string | null | undefined
  • prefersDark boolean
  • options ThemeBootstrapOptions

    optional · 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 = {}): ThemeBootstrapState

View source

Parameters

  • preference ThemeBootstrapPreference
  • options ThemeBootstrapOptions

    optional · default: {}

Returns

ThemeBootstrapState