@duro-app/ui

中文文档
6.1.0发布于 2026/11/12MITTypeScriptES Module近 30 天下载 6811

Duro's components, written with react-strict-dom: one source for the web and for React Native. Component docs, props and recipes: npx @duro-app/cli <Name>, or the repository's CLAUDE.md.

原始使用文档

@duro-app/ui

Duro's components, written with react-strict-dom: one source for the web and for React Native. Component docs, props and recipes: npx @duro-app/cli <Name>, or the repository's CLAUDE.md.

pnpm add @duro-app/ui @duro-app/tokens react-strict-dom react-hook-form

React Native

Metro resolves the package's react-native export condition to src/index.native.ts, a barrel of the components that have a native variant (npx @duro-app/cli <Name> says native: true); @duro-app/ui/form resolves to src/form.native.ts. babel-preset-expo compiles the source.

Peers. Metro does not tree-shake, so on native every one of these is required, though npm lists them as optional (they are the web build's optional peers):

PeerFor
react-native ≥ 0.81the platform
react-native-gesture-handler ^2.28sheet drags, Toast swipe
react-native-reanimated ≥ 4.1, react-native-worklets ≥ 0.5gestures and Spinner on the UI thread
react-native-safe-area-context ^5.6insets (mount its SafeAreaProvider; expo-router does)
react-native-svg ^15.12Icon and the glyphs
react-hook-form ^7.55Field binding (a required peer on both platforms)
@hookform/resolvers ^5, effect ^3only for @duro-app/ui/form

One copy of each. Resolve react, react-native, the native peers, react-strict-dom, react-hook-form, @hookform/resolvers, effect and @duro-app/* from the app, so the bundle has one React renderer and one react-strict-dom. With a linked or workspace copy of Duro, a Metro resolveRequest that resolves those names from the app's package.json does it; examples/native/metro.config.mjs in this repository is one.

What differs on native.

  • Dialog, Drawer, Menu, Popover and the Select and Combobox sheets render in an RN Modal; Toast draws through a portal host. Mount PortalHost inside a natively presented route so toasts draw above it.
  • Select and Combobox open a bottom sheet; Tooltip draws nothing and gives its text to the trigger as an accessibility hint.
  • A type="submit" Button inside Form submits it (there is no DOM submit event).
  • There are no arrow keys: keyboard navigation is the web's; native gets the screen-reader roles and states.

版本与发布记录

@duro-app/ui 共发布 166 个版本,首次发布于 2026/03/02;过去 12 个月发布了 166 个版本。

版本发布日期距今
6.1.0latest2026/11/121 天前
6.0.02026/11/085 天前
5.45.02026/11/0211 天前
5.44.02026/11/0211 天前
5.43.02026/11/0211 天前
5.42.02026/11/0211 天前

关于 @duro-app/ui 的常见问题

@duro-app/ui 是什么?

Duro's components, written with react-strict-dom: one source for the web and for React Native. Component docs, props and recipes: npx @duro-app/cli <Name>, or the repository's CLAUDE.md.

如何安装 @duro-app/ui?

在项目目录运行 npm install @duro-app/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^19.0.0)、react-dom(^19.0.0)、react-hook-form(^7.55.0)、react-strict-dom(^0.0.55)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@duro-app/ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@duro-app/ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@duro-app/ui 可以商用吗?

@duro-app/ui 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@duro-app/ui 的下载量有多少?

根据 npm 官方下载统计,@duro-app/ui 在 2026/10/13 – 2026/11/11 这 30 天内被下载 6,811 次,日均约 227 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@duro-app/ui 还在维护吗?

最新版本 6.1.0 发布于 2026/11/12(1 天前);至今共发布 166 个版本,其中过去 12 个月发布了 166 个;首次发布于 2026/03/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。