Features
- Defaults to a single host
- Supports multiple hosts
- Supports multiple portals for a single host
component. -->
Portals let you render its children into a different part of your app.
Features
Install the component via your command line.
Install zustand
Copy/paste the following code to ~/components/primitives/portal.tsx
Add the <PortalHost />
as the last child of your <Root/>
component (for expo-router, the default export in the root _layout.tsx
)
Then, from any component, add a <Portal />
and its content will be rendered as a child of <PortalHost />
Add the <PortalHost name="unique-host-name"/>
with a unique name where you want the contents of <Portal />
to render. Then, from any component, add a <Portal />
and its content will be rendered as a child of <PortalHost />
By default, children of all Portal components will be rendered as its own children.
Prop | Type | Note |
---|---|---|
name | string | Provide when it is used as a custom host (optional) |
Prop | Type | Note |
---|---|---|
name* | string | Unique value otherwise the portal with the same name will replace the original portal |
hostName | string | Provide when its children are to be rendered in a custom host (optional) |