@erxes/ui

中文文档
3.4.22发布于 2026/11/13AGPL-3.0-onlyTypeScriptES Module近 30 天下载 2638

erxes design system: UI primitives, business modules, hooks and shared frontend state

原始使用文档
文档目录3 节
  1. Install in a React application
  2. Build the npm package
  3. Running unit tests

erxes-ui

Shared React components, business modules, hooks, and frontend state for erxes.

Install in a React application

npm install @erxes/ui
import { Button } from '@erxes/ui';

export function Example() {
  return <Button onClick={() => window.alert('Hello')}>Continue</Button>;
}

The published package contains JavaScript and automatically imports its compiled stylesheet. Vite source aliases, process.env shims, Tailwind plugins, source scanning, and copied theme declarations are not required to render components. Match the React version with the package's peer dependencies.

Component subpaths also include the stylesheet:

import { Button } from '@erxes/ui/components/button';

The stylesheet covers the classes used by the library. Configure Tailwind in your application if you want to generate additional utility classes of your own. Override CSS variables such as --primary to customize the default theme. Add the dark class to a parent element to select the dark theme.

The stylesheet also sets the page defaults erxes apps share (src/base.css): the default light and dark theme, theme border colour on every element, page background and text colour, and heading sizes. A standalone app that is not hosted by core-ui only needs this stylesheet, plus @erxes/ui/fonts.css to load Inter and Roboto Mono (core-ui loads them from its index.html).

@erxes/ui/theme.css remains available for applications that already compile Tailwind and supply their own design tokens. The compiled stylesheet is also exported as @erxes/ui/styles.css and @erxes/ui/style.css.

Components that use routing, GraphQL, translations, or shared state still need their corresponding application providers. The ready-to-use stylesheet does not configure those services.

Build the npm package

pnpm nx build erxes-ui
pnpm --filter erxes-ui test:package
pnpm --dir frontend/libs/erxes-ui/dist pack

The build writes a standalone dist/package.json, JavaScript entries, type declarations, and compiled CSS. The existing theme.css contract and the default tokens in src/base.css (also imported by core-ui) are compiled into it. The publish workflow packs this directory and applies the shared platform version. Workspace consumers continue to resolve the original source exports.

Declaration emission retains the shared-libraries workflow's existing policy: type diagnostics are reported, while declaration-emit failures fail the build.

Running unit tests

Run nx test erxes-ui to execute the unit tests via Jest.

版本与发布记录

@erxes/ui 共发布 61 个版本,首次发布于 2026/10/12;过去 12 个月发布了 61 个版本。

版本发布日期距今
3.4.22latest2026/11/13今天
4.0.0-v2.0v2-next2026/11/13今天
3.4.22-next.1next2026/11/13今天
3.4.212026/11/131 天前
3.4.21-next.12026/11/121 天前
3.4.202026/11/121 天前

关于 @erxes/ui 的常见问题

@erxes/ui 是什么?

erxes design system: UI primitives, business modules, hooks and shared frontend state

如何安装 @erxes/ui?

在项目目录运行 npm install @erxes/ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:jotai(^2.12.0)、react(^18.3.1)、graphql(^16.10.0)、react-dom(^18.3.1)、react-i18next(^15.1.1)、@apollo/client(^3.11.8)、react-router-dom(^7.1.1)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@erxes/ui 支持 TypeScript 吗?

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

@erxes/ui 支持 ESM 还是 CommonJS?

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

@erxes/ui 可以商用吗?

@erxes/ui 使用 AGPL-3.0-only 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@erxes/ui 的下载量有多少?

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

@erxes/ui 还在维护吗?

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