@deskpro/deskpro-ui

中文文档
10.0.3发布于 2026/10/27BSD-3-ClauseTypeScriptESM + CJS近 30 天下载 5253

Deskpro UI components

原始使用文档
文档目录3 节
  1. Documentation
  2. Usage
  3. Styling props are transient ( $ )

@deskpro/deskpro-ui

Deskpro UI component library

Documentation

Usage

Supports React 18 and 19 (react / react-dom ^18 || ^19) and styled-components 5 and 6 (^5 || ^6). TypeScript consumers need TypeScript 4.7 or later.

# Add deskpro-ui and peer deps
pnpm add @deskpro/deskpro-ui react react-dom styled-components

# Add types
pnpm add -D @typescript/lib-dom@npm:@types/web
# styled-components 5 only (v6 ships its own types)
pnpm add -D @types/styled-components
// Optional CSS - depending which components are used from dp-ui and whether you have your own reset css
// Either download and save to an assets dir or install modern-normalize and simplebar-react as direct dependencies and reference directly from node modules
import "modern-normalize/modern-normalize.css";
import "simplebar-react/dist/simplebar.min.css";

// Required CSS
import "@deskpro/deskpro-ui/dist/deskpro-ui.css";
import "@deskpro/deskpro-ui/dist/deskpro-custom-icons.css";

import React from "react";

import { Stack, Button, lightTheme } from "@deskpro/deskpro-ui";
import { ThemeProvider } from "styled-components";

export function App() {
  return (
    <ThemeProvider theme={lightTheme}>
      <Stack>
        <Button text="hi" />
      </Stack>
    </ThemeProvider>
  );
}

To type theme in your own styled components, augment styled-components' DefaultTheme:

import type { DeskproTheme } from "@deskpro/deskpro-ui";

declare module "styled-components" {
  export interface DefaultTheme extends DeskproTheme {}
}

Styling props are transient ($)

Props that only style a component and aren't HTML attributes are $-prefixed transient props, e.g. <Stack $gap={4} $vertical $align="center"> and <TSpan type="p_p1" $themeColor="grey100">. styled-components never writes $ props to the DOM, so deskpro-ui needs no StyleSheetManager or other setup on styled-components 5 or 6.

版本与发布记录

@deskpro/deskpro-ui 共发布 176 个版本,首次发布于 2022/02/02;过去 12 个月发布了 17 个版本。

版本发布日期距今
10.0.3latest2026/10/2715 天前
10.0.22026/10/2320 天前
10.0.12026/10/1923 天前
10.0.02026/09/251 个月前
9.3.22026/08/063 个月前
9.3.12026/07/283 个月前

其他发布通道:next → 7.11.0-next.0。

关于 @deskpro/deskpro-ui 的常见问题

@deskpro/deskpro-ui 是什么?

Deskpro UI components

如何安装 @deskpro/deskpro-ui?

在项目目录运行 npm install @deskpro/deskpro-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^18 || ^19)、react-dom(^18 || ^19)、styled-components(^5 || ^6)、@typescript/lib-dom(npm:@types/web)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@deskpro/deskpro-ui 支持 TypeScript 吗?

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

@deskpro/deskpro-ui 支持 ESM 还是 CommonJS?

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

@deskpro/deskpro-ui 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 20.16.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@deskpro/deskpro-ui 可以商用吗?

@deskpro/deskpro-ui 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@deskpro/deskpro-ui 还在维护吗?

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