@gitlab/duo-ui

中文文档
16.9.7发布于 2026/11/16MITTypeScriptESM + CJS近 30 天下载 23.2万

Duo UI Components

原始使用文档
文档目录9 节
  1. Storybook
  2. Usage
  3. Quick start - development
  4. Testing
  5. Unit tests
  6. Visual regression tests
  7. Releases
  8. Contributing guide
  9. FAQs

Duo UI

Duo UI is a library that is home to all Duo Components which are shared across multiple Host systems.

Storybook

Latest main branch: https://gitlab-org.gitlab.io/duo-ui/

Usage

  1. To use Duo UI in your project, add it as a dependency:

    yarn add @gitlab/duo-ui
    

    Note: Make sure to also install Duo UI's peer dependencies. Refer to the package.json for the list of peer dependencies and their expected versions.

Quick start - development

Note: Duo UI isn't designed to be built on Windows natively. Either WSL or GitPod can be used to set up a UNIX-like environment in which to build it.

Make sure you have Node 16.x (LTS) and Yarn 1.22 or newer.

# Clone the project
git clone [email protected]:gitlab-org/duo-ui.git

# Navigate to the root of the project
cd duo-ui

# Install all the dependencies of the project
yarn # or yarn install

# Build and launch storybook to see the components in the browser
yarn storybook

Go to http://localhost:9001/

Testing

Unit tests

Components’ unit tests live in the tests/components. The tests are organized following the same directory structure used to organize components.

  • yarn test:unit runs all unit tests.

  • yarn test:unit:watch runs all unit tests in watch mode.

  • yarn test:unit:debug runs all unit tests and allows attaching a debugger to the test runner process.

  • yarn jest [name_pattern] runs spec files that match the specified name pattern.

Examples

  • yarn jest datepicker will match all spec files with a name that contains the word datepicker.

  • yarn jest datepicker -t "when draw event is emitted" goes a step further and only runs the test with a description that matches the argument passed to the t flag.

Visual regression tests

Duo UI uses visual snapshot tests to prevent introducing regressions with CSS and layout changes on components. Read more on this in the visual testing documentation.

Releases

See Updating Duo UI Packages for information on how the @gitlab/duo-ui package is kept up to date in various projects.

Contributing guide

Please refer to CONTRIBUTING.md for details on how to add new components and contribute in general to Duo UI.

FAQs

Any question? Have a look at our FAQ.md, you might find the answer there.

版本与发布记录

@gitlab/duo-ui 共发布 287 个版本,首次发布于 2024/10/25;过去 12 个月发布了 126 个版本。

版本发布日期距今
16.9.7latest2026/11/16今天
16.9.62026/11/123 天前
16.9.52026/11/0610 天前
16.9.42026/11/0511 天前
16.9.32026/11/0412 天前
16.9.22026/11/0313 天前

关于 @gitlab/duo-ui 的常见问题

@gitlab/duo-ui 是什么?

Duo UI Components

如何安装 @gitlab/duo-ui?

在项目目录运行 npm install @gitlab/duo-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^2.7.16)、pikaday(^1.8.0)、bootstrap(>=4.5.3 <=4.6.2)、dompurify(>=2.5.2 <3.0.0 || >=3.1.2)、@gitlab/ui(>=112.3.1)、emoji-regex(>=10.0.0)、tailwindcss(^3)、@gitlab/svgs(^1.116.0 || ^2.0.0 || ^3.0.0)、highlight.js(>=11.0.0 <12.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@gitlab/duo-ui 支持 TypeScript 吗?

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

@gitlab/duo-ui 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@gitlab/duo-ui 可以商用吗?

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

@gitlab/duo-ui 的下载量有多少?

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

@gitlab/duo-ui 还在维护吗?

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