expo-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseExpo UI (@expo/ui
)
@expo/uiExpo UI (@expo/ui
)
@expo/ui@expo/uiThese instructions track the latest Expo SDK. The universal layer requires SDK 56+. Drop-in replacements and the platform-specific layers also exist on SDK 55. For component details on a specific SDK, refer to the Expo UI docs for that version.
@expo/ui这些说明基于最新的Expo SDK。通用层需要 SDK 56+。可直接替换的组件和平台特定层在SDK 55中也已存在。如需特定SDK的组件详情,请参考对应版本的Expo UI文档。
Installation
安装
bash
npx expo install @expo/uiOn SDK 56, works in Expo Go, so runs it directly — no custom build required. On older SDKs, build a dev client first ( / ).
@expo/uinpx expo startnpx expo run:iosnpx expo run:androidEvery tree — universal or platform-specific — must be wrapped in .
@expo/uiHostbash
npx expo install @expo/ui在SDK 56中,可在Expo Go中运行,因此直接执行即可——无需自定义构建。在旧版SDK中,请先构建开发客户端( / )。
@expo/uinpx expo startnpx expo run:iosnpx expo run:android所有树——无论是通用还是平台特定的——都必须包裹在中。
@expo/uiHostChoosing an approach (read this first)
选择合适的方案(请先阅读本节)
Work down this list and stop at the first layer that meets the need:
-
Universal components — start here. Import from theroot. One component tree runs unmodified on iOS, Android, and web from a single source (Compose on Android, SwiftUI on iOS,
@expo/ui/react-native-webon web). No platform file splits. →react-dom./references/universal.md -
Platform-specific (SwiftUI / Jetpack Compose). Import fromor
@expo/ui/swift-ui. Use only when the universal layer is missing a component or modifier you need, or when you need platform-specific behavior or optimization. Downside: you write two trees and split them into@expo/ui/jetpack-compose/.ios.tsxfiles (or branch on.android.tsx) — more code to maintain. →Platform.OSand./references/swift-ui.md./references/jetpack-compose.md
Already using an RN community UI library? also ships drop-in replacements — API-compatible swaps for popular libraries (, , and more), imported from . This is a migration side-path for replacing an existing dependency, not a step in the universal-vs-platform decision above. →
@expo/ui@gorhom/bottom-sheet@react-native-community/datetimepicker@expo/ui/community/<name>./references/drop-in-replacements.md按以下顺序选择,找到第一个满足需求的层级即可:
-
通用组件——从这里开始。从根目录导入。一套组件树无需修改即可在iOS、Android和Web上运行(Android端用Compose,iOS端用SwiftUI,Web端用
@expo/ui/react-native-web)。无需按平台拆分文件。→react-dom./references/universal.md -
平台特定组件(SwiftUI / Jetpack Compose)。从或
@expo/ui/swift-ui导入。仅在通用层缺少所需组件或修饰符,或者需要平台特定行为或优化时使用。缺点:需要编写两套组件树,并拆分为@expo/ui/jetpack-compose/.ios.tsx文件(或基于.android.tsx分支处理)——需要维护更多代码。→Platform.OS和./references/swift-ui.md./references/jetpack-compose.md
已在使用React Native社区UI库? 还提供了可直接替换的组件——与热门库(如、等)API兼容的替代组件,从导入。这是替换现有依赖的迁移路径,不属于上述通用vs平台特定方案的选择步骤。→
@expo/ui@gorhom/bottom-sheet@react-native-community/datetimepicker@expo/ui/community/<name>./references/drop-in-replacements.mdReferences
参考资料
Consult these resources as needed:
references/
universal.md Universal @expo/ui components and when to use them (SDK 56+)
drop-in-replacements.md API-compatible replacements for RN community UI libraries
swift-ui.md Platform-specific iOS UI: @expo/ui/swift-ui components, modifiers, RNHostView, useNativeState
jetpack-compose.md Platform-specific Android UI: @expo/ui/jetpack-compose components, modifiers, LazyColumn caveat, icons, useNativeState按需查阅以下资源:
references/
universal.md 通用@expo/ui组件及其适用场景(SDK 56+)
drop-in-replacements.md 与React Native社区UI库API兼容的替代组件
swift-ui.md 平台特定iOS UI:@expo/ui/swift-ui组件、修饰符、RNHostView、useNativeState
jetpack-compose.md 平台特定Android UI:@expo/ui/jetpack-compose组件、修饰符、LazyColumn注意事项、图标、useNativeState