You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/advanced-topics/portals.mdx
+10-3Lines changed: 10 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,24 @@ title: "Portals"
3
3
description: "Rendering into out-of-tree DOM nodes"
4
4
---
5
5
6
-
## How to think about portals?
6
+
## What is a portal?
7
7
8
8
Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
9
9
`yew::create_portal(child, host)` returns a `Html` value that renders `child` not hierarchically under its parent component,
10
10
but as a child of the `host` element.
11
11
12
12
## Usage
13
13
14
-
Typical uses of portals can include modal dialogs and hovercards, as well as more technical applications such as controlling the contents of an element's [`shadowRoot`](https://developer.mozilla.org/en-US/docs/Web/API/Element/shadowRoot), appending stylesheets to the surrounding document's `<head>` and collecting referenced elements inside a central `<defs>` element of an `<svg>`.
14
+
Typical uses of portals can include modal dialogs and hovercards, as well as more technical applications
stylesheets to the surrounding document's `<head>` and collecting referenced elements inside a
18
+
central `<defs>` element of an `<svg>`.
15
19
16
-
Note that `yew::create_portal` is a rather low-level building block, on which other components should be built that provide the interface for your specific use case. As an example, here is a simple modal dialogue that renders its `children` into an element outside `yew`'s control, identified by the `id="modal_host"`.
20
+
Note that `yew::create_portal` is a low-level building block. Libraries should use it to implement
21
+
higher-level APIs which can then be consumed by applications. For example, here is a
22
+
simple modal dialogue that renders its `children` into an element outside `yew`'s control,
0 commit comments