Skip to main content

Module html

Module html 

Source
Expand description

The HtmlUi component and what it produces.

Spawn HtmlUi with a template handle; its required components (Node, TemplateContext, RenderedHtml, …) are added for you, so override any of them in the same bundle. The entity’s children are owned by the pipeline: they’re despawned and rebuilt whenever the template, context or locale change (HtmlUiBuilt), and restyled in place when the stylesheet or fonts change (HtmlUiRestyled).

Tags decide structure:

  • blocks: h1–h6, p, li (bulleted), pre (whitespace and line breaks kept, no wrapping), and loose text directly inside a container
  • containers: div, section, article, header, footer, main, nav, aside, ul, ol, blockquote, figure, form — column nodes holding their children’s nodes, spaced like the HtmlUi node’s own row_gap unless CSS sets gap
  • any other element is inline (styled text inside a block) or, outside a block, walked through without a node (html, body, unknown tags); head/script/style are skipped

Each block is spawned as a Text with one TextSpan per styled run. Blocks and containers carry an HtmlElement (anonymous loose text doesn’t), so CSS selectors and HtmlElements reach them.

Structs§

HtmlDebugOutline
Show the DOM outline (elements, attributes, text, translations) instead of the rendered UI — for debugging templates. Styled like the stylesheet’s pre. Also logged at debug level on every rebuild.
HtmlElement
The HTML element a spawned block node came from.
HtmlElements
Finds spawned HtmlElements below an HtmlUi entity.
HtmlUi
A Bevy UI subtree rendered from an HTML template.
HtmlUiBuilt
Fired on an HtmlUi entity after its children were (re)built. Children are replaced on every rebuild — template, context, locale or outline changes — so attach behaviour (observers, components) here rather than once at spawn. Style-only changes restyle the existing children instead and fire HtmlUiRestyled.
HtmlUiRestyled
Fired on an HtmlUi entity after a style-only change (stylesheet swap or reload, a frame image loading, FontFamilies) restyled its existing children in place. The entities — and whatever the app attached to them on HtmlUiBuilt — are kept, so there’s nothing to re-wire. When the new styles need a different node structure (e.g. box properties appearing on a block, which then needs a wrapper node), the children are rebuilt and HtmlUiBuilt fires instead.
TemplateContext
Tera variables for this entity’s template. Mutate it (it derefs to tera::Context) to re-render.

Enums§

RenderedHtml
The template’s latest render. Read-only for users; written by HtmlUiSystems::Render.