Method Portal
- Namespace
- Velvet
- Assembly
- Velvet.Docs.dll
Portal(string, VNode?[]?, string?)
Renders children into the Portal target identified by targetId,
detaching them from the surrounding DOM position so they mount under a different host element.
targetId must reference an ID previously registered via FiberPortalRegistry.Register.
public static PortalNode Portal(string targetId, VNode?[]? children = null, string? key = null)
Parameters
targetIdstringPortal target ID registered via
FiberPortalRegistry.Register.childrenVNode[]Descendant VNodes mounted into the resolved portal target.
keystringKey used to disambiguate siblings at the same position.
Returns
- PortalNode
The created PortalNode.
Remarks
Behavior boundary: context inheritance follows the LOGICAL tree (children inherit the context enclosing the V.Portal call site), but EVENT BUBBLING does NOT. Velvet physically reparents the children under the registered target element, so UI Toolkit bubbles their pointer / click / change events up the target's PHYSICAL ancestor chain — not up the logical ancestors of the V.Portal call site. A handler that must observe a portal child's event has to be placed on the target element's own ancestor chain (or attached directly to the portal children). The idealized model — where portal events also bubble through the logical tree — is not reproducible here: UI Toolkit computes every event's propagation path from the physical visual tree and exposes no API to redirect it along a logical chain, so faithful logical bubbling would require re-implementing the dispatcher (which would double-fire handlers on shared ancestors and could recurse across nested portals).
Portal(UILayer, VNode?[]?, string?)
Renders children into a framework-managed screen-space layer panel
sorted around the app's main panel — one host panel per layer per reconciler, created
lazily and destroyed with the reconciler. Like every portal, the children stay part of the
LOGICAL tree (context and state cross the boundary) while attaching physically to the layer
panel — so event bubbling, relational group-/peer- variants and focus-within
do not cross, and responsive breakpoints evaluate against the layer panel's own width.
Screen-space layers always composite over the 3D scene; UI that must sit among scene
geometry is WorldSpace(Vector3, Quaternion?, Vector2?, VNode?[]?, string?)'s territory.
public static PortalNode Portal(UILayer layer, VNode?[]? children = null, string? key = null)
Parameters
layerUILayerThe framework-managed layer panel to attach the children to.
childrenVNode[]Descendant VNodes mounted into the layer panel.
keystringKey used to disambiguate siblings at the same position.
Returns
- PortalNode
The created PortalNode.