Skip to content

theme-bootstrap.ts#

View Markdown

Source

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

7 symbols 7 functions 12 parameters 7 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
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 = {}): string

View source

Parameters

  • options ThemeBootstrapOptions

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

View source

Parameters

  • options ThemeBootstrapOptions

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

View source

Parameters

  • options ThemeBootstrapOptions

    optional · default: {}

  • renderOptions RenderThemeBootstrapScriptOptions

    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