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.
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 }}).
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 all safe areas
Use ignoreSafeArea="all" when you want SwiftUI content to extend behind the status bar, useful for full-screen overlays or backgrounds.
API
import { Host } from '@expo/ui/swift-ui';
No API data file found, sorry!