One Logo Pool Ball
wwwwwwwwwwwwwwwwwww

Portal

Move React content into a named native host.

One.UI.Portal on iOS and Android: a menu declared inside one list row, drawn above the whole screen

One.UI.Portal renders its children inside a One.UI.PortalHost somewhere else in the app. The children stay in their place in the React tree.

Usage

Mount a host where the content should appear, then name it from a portal. The host draws portals above its own children.

import { One } from 'one'
import { StyleSheet, View } from 'react-native'
export function Screen() {
return (
<View style={{ flex: 1 }}>
<MessageList />
<One.UI.PortalHost name="overlay" style={StyleSheet.absoluteFill} />
</View>
)
}
function MessageRow({ menuOpen }: { menuOpen: boolean }) {
return (
<View style={{ overflow: 'hidden' }}>
<RowContent />
{menuOpen && (
<One.UI.Portal hostName="overlay" name="menu">
<RowMenu />
</One.UI.Portal>
)}
</View>
)
}

The menu escapes the row’s clip because it renders in the host, yet it still reads the row’s context and state.

API reference

Portal

Portal also accepts React Native ViewProps, applied to the view that wraps its children.

PropsTypeDescription
children (required)ReactNodeThe content to move.
ReactNodeThe content to move.
hostNamestringThe host to render in. Without it, children render in place.
stringThe host to render in. Without it, children render in place.
namestringA later portal with the same name in the same host replaces this one.
stringA later portal with the same name in the same host replaces this one.

PortalHost

PortalHost also accepts React Native ViewProps. style sizes the host.

PropsTypeDescription
name (required)stringThe name portals use as their hostName.
stringThe name portals use as their hostName.
childrenReactNodeThe host's own content, drawn below its portals.
ReactNodeThe host's own content, drawn below its portals.

Behavior

iOSAndroidWeb
HostFabric viewNative view groupStable DOM container
LayoutHost size measured natively, no JS round tripSameCSS

Migrating from react-native-teleport

Replace imports from react-native-teleport with One.UI.Portal and One.UI.PortalHost, remove PortalProvider, and mount any root overlay host yourself. @tamagui/native/setup-teleport keeps its import path and binds Tamagui portals to these components.

Edit this page on GitHub.