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 theHtmlUinode’s ownrow_gapunless CSS setsgap - 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/styleare 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§
- Html
Debug Outline - Show the DOM outline (elements, attributes, text, translations) instead of
the rendered UI — for debugging templates. Styled like the stylesheet’s
pre. Also logged atdebuglevel on every rebuild. - Html
Element - The HTML element a spawned block node came from.
- Html
Elements - Finds spawned
HtmlElements below anHtmlUientity. - HtmlUi
- A Bevy UI subtree rendered from an HTML template.
- Html
UiBuilt - Fired on an
HtmlUientity 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 fireHtmlUiRestyled. - Html
UiRestyled - Fired on an
HtmlUientity 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 onHtmlUiBuilt— 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 andHtmlUiBuiltfires instead. - Template
Context - Tera variables for this entity’s template. Mutate it (it derefs to
tera::Context) to re-render.
Enums§
- Rendered
Html - The template’s latest render. Read-only for users; written by
HtmlUiSystems::Render.