Expo UI Background matches the official SwiftUI background modifier and draws background content behind a view, positioned with a specified alignment. The base view keeps its own size.
To fill a view with a color, material, or gradient, use the background modifier from @expo/ui/swift-ui/modifiers.
Use the alignment prop to position the background content relative to the base view. Because the background does not affect the layout of the base view, a smaller background can be pinned to one of its edges.
BackgroundAlignmentExample.tsx
import{Background,Host,Rectangle,Text,}from'@expo/ui/swift-ui';import{
font,
foregroundStyle,
frame,}from'@expo/ui/swift-ui/modifiers';exportdefaultfunctionBackgroundAlignmentExample(){return(<Hoststyle={{
flex:1,
justifyContent:'center',
alignItems:'center',}}><Backgroundalignment="bottom"><Textmodifiers={[font({ size:17})]}>
Underlined by its background
</Text><Background.Content><Rectanglemodifiers={[frame({ height:3}),foregroundStyle('#007AFF'),]}/></Background.Content></Background></Host>);}