Reference
Portal
Its block, drawn into a node somebody else's code owns: an element a script hands over, or a ref: handle. When into: names another node the block moves there with its nodes and state; null keeps it aside until a node comes back; it goes when the page, branch or list item it is written in leaves. What is inside belongs to where it is written: its handlers, emit and lifetimes.
Portal(into: Element?) { … }
Since 5.10.0
No props to try.
A node somebody else's code owns:
Example
state count = 0
Stack(gap: .sm, ref: panel) {
style { padding: 1rem; border: 1px dashed $color-border; border-radius: $radius-md }
Text("A node somebody else's code owns:").muted.sm
}
Portal(into: panel) {
Row(gap: .sm, align: .center) {
Text("Clicked {count} times")
Button("Click").primary.sm { on click { count = count + 1 } }
}
}
Props
| Prop | Type | Unset | Meaning |
|---|---|---|---|
into: | Element? (required) | — | Where it draws: an element, a |
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
children
Renders with the class wf-portal, 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.