This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
Host
A SwiftUI Host component that enables SwiftUI components in React Native.
For cross-platform usage, see the universal
Host— it renders the appropriate native component per platform.
A component that allows you to put the other @expo/ui/swift-ui components in React Native. It acts like <svg> for DOM, <Canvas> for react-native-skia, which internally uses UIHostingController to render the SwiftUI views in UIKit.
Since the Host component is a React Native View, you can pass the style prop to it or matchContents prop to make the Host component match the contents' size.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Match contents sizing
Use matchContents to let the Host automatically size itself to fit its SwiftUI content, instead of requiring explicit dimensions.
Note:
matchContentsonly works correctly with components that have an intrinsic size or an explicitframe(for example,Button,Toggle,Text). Flexible-width components likeSliderand linearProgressViewexpand to fill available space and have no intrinsic width, usingmatchContentswith them will result in near-zero width. For those components, either apply aframemodifier on the component to give it an explicit width, or use explicit sizing withstyleon theHostinstead (for example,style={{ flex: 1 }}orstyle={{ width: 300 }}).
Note: Do not use
matchContentson the same axis as a scroll container (ScrollView,List,Form,LazyHStack,LazyVStack).matchContentsresolves to SwiftUI's.fixedSize, which sizes the scroll container to its content. It also leaves nothing past the viewport to scroll into, so scrolling silently stops working. UsematchContents={{ vertical: true }}together withstyle={{ width: '100%' }}(or any finite width on the scroll axis).
Explicit sizing with style
Use style to set explicit sizes on the Host, such as filling the available space with flex: 1.
Ignoring keyboard safe area
Use ignoreSafeArea="keyboard" when React Native is already handling keyboard avoidance (for example, with react-native-keyboard-controller), to prevent the SwiftUI host from applying its own keyboard inset.
Ignoring the container safe area
Use ignoreSafeArea="container" to remove only the container safe area (notch, home indicator, status and navigation bars). The keyboard safe area still applies.
Ignoring all safe areas
Use ignoreSafeArea="all" when you want SwiftUI content to extend behind the status bar and the keyboard, useful for full-screen overlays or backgrounds.
API
import { Host } from '@expo/ui/swift-ui';
No API data file found, sorry!