Reference
Host
A bare node handed to somebody else's code, with a lifetime. mount: runs with the node each time it is made, update: again whenever the state it reads changes, and cleanup: when the page, branch or list item it belongs to leaves. Every other element takes the same three.
Host(tag: String)
Before 5.0
No preview for this one: the example below shows how it is written.
Example
state level = 40
Slider(bind: level, min: 0, max: 100, label: "Level")
Host(tag: "canvas", aria-label: "A bar at {level}%",
mount: (node) => node.getBoundingClientRect(),
update: (box) => console.log("redraw at {level}% across {box.width}px"),
cleanup: (box) => console.log("canvas gone")) {
style { width: 100%; height: 120px; border: 1px dashed $color-border }
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
tag: | String | div | The element to make: |
Attribute families: global, aria, data. Plus the 22 universal props every element takes: animate:, exit:, speed:, duration:, delay:, easing:, stagger:, on:, count:, shared:, class:, ref:, drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, roving:, trapFocus:, mount:, update:, cleanup:.
Flags and cases
A flag is written after the parentheses with a dot: a Bool prop, or a case of one of the element's enum props. A case the enum lacks is an error with a hint.
No flags of its own.
Events
Every element also takes the props, the events and the attribute families listed on every element.
Slots
It takes no slots.
Renders with the class wf-host, stable across releases, so a stylesheet may target it.
Codes this can raise
These controls list the props' cases; the example below shows them written.