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: README.md
+13-9
Original file line number
Diff line number
Diff line change
@@ -115,21 +115,25 @@ How does it work under the hood?
115
115
116
116
This creates a detached DOM node, with a little extra functionality attached to allow transmitting props later on.
117
117
118
-
This node will contain your portal contents later, within a `<div>`, and will eventually be attached in the target location.
118
+
This node will contain your portal contents later, and will eventually be attached in the target location.
119
119
120
-
An optional options object parameter can be passed to configure the node. The only supported option is `attributes`: this can be used to set the HTML attributes (style, class, etc.) of the intermediary, like so:
120
+
An optional options object parameter can be passed to configure the node.
-`options.containerElement` (default: `div`) can be set to `'span'` to ensure valid HTML (avoid React hydration warnings) when portaling into [phrasing content](https://developer.mozilla.org/en-US/docs/Web/HTML/Content_categories#phrasing_content).
123
+
124
+
-`options.attributes` can be used to set the HTML attributes (style, class, etc.) of the intermediary, like so:
127
125
128
-
The div's DOM node is also available at `.element`, so you can mutate that directly with the standard DOM APIs if preferred.
The detached DOM node is also available at `.element`, so you can mutate that directly with the standard DOM APIs if preferred.
129
133
130
134
### `portals.createSvgPortalNode([options])`
131
135
132
-
This creates a detached SVG DOM node. It works identically to the node from `createHtmlPortalNode`, except it will work with SVG elements. Content is placed within a `<g>` instead of a `<div>`.
136
+
This creates a detached SVGDOMnode. It works identically to the node from `createHtmlPortalNode`, except it will work withSVGelements. Content is placed within a `<g>` instead of a `<div>` by default, which can be customized by `options.containerElement`.
133
137
134
138
An error will be thrown if you attempt to use a HTML node forSVG content, or a SVG node forHTML content.
0 commit comments