# @capra/theme 中文文档

规范地址：https://npmcn.com/package/%40capra/theme/

版本：2\.0\.0
npm 元数据更新时间：2026-11-06T19:20:40.600Z
中文译文更新时间：2026-11-09T05:00:32.211Z
软件包许可：SEE LICENSE IN LICENSE\.txt

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40capra/theme
原文对照：https://npmcn.com/package/%40capra/theme/?lang=original
项目主页：https://capra.cribl.io/

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：3.2 MB，49 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- 运行依赖：0 个
- 首次发布：2026-06-16T20:59:51.941Z
- 最新版本发布：2026-11-06T19:20:40.442Z
- 近 30 天下载量：10523（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：11（近 12 个月 11 个）

## 中文简介

卡普拉设计系统的主题资源

## 安装

```sh
npm install @capra/theme
```

也可以使用：`pnpm add @capra/theme`、`yarn add @capra/theme`、`bun add @capra/theme`

## README

# @ capra/ 主题

## 概览

`@capra/theme` 提供消费者使用的 Capra 基线样式表、 符号助手和 DX 符号进入点, 并构建工具.

## 文档

人可读文件可在 [https://capra.cribl.io (中文(简体) )](https://capra.cribl.io/)。 。 。 .

可读 LLM 文档可在 [https://capra.cribl.io/llms.txt](https://capra.cribl.io/llms.txt)。 。 。 .

## 安装

```sh
pnpm add @capra/theme
```

## 使用量

```ts
import '@capra/theme/base.css';
import { token } from '@capra/theme';

const gap = token('spacing.md');
```

图表和数据可视化主题可查阅: `@capra/theme/visualizations`。每个主题都包含具体值,如六分色和像素维度,因此它们与画布渲染器和其他无法解决CSS变量的环境一起工作。 同名导师住在Docs网站 [可视化主题](https://capra.cribl.io/?path=/docs/foundation-design-tokens-visualization--docs)。 。 。 .

```ts
import { getChartTheme, getEchartsTheme } from '@capra/theme/visualizations';

const genericTheme = getChartTheme({
  palette: 'sequential.Viridis',
  mode: 'dark',
});

const echartsTheme = getEchartsTheme({
  palette: 'categorical.observable10',
  mode: 'light',
});
```

在初始化图表前登记ECharts主题 :

```ts
import * as echarts from 'echarts';
import { getEchartsTheme } from '@capra/theme/visualizations';

echarts.registerTheme(
  'capra',
  getEchartsTheme({
    palette: 'categorical.observable10',
    mode: 'dark',
  }),
);

const chart = echarts.init(element, 'capra');
```

使用 `visualizationPaletteNames` 财务报告和审定财务报表 `visualizationThemeModes` 来填充选择器或列出每个支持的排列.

可用的样式表条目点 :

-   `@capra/theme/base.css` 是首选的基准样式表。 它包括了Capra设计符,字体面声明,以及最低限度的全球默认.
-   `@capra/theme/styles.css` 是用于向后兼容的仅保留变量样式表.
-   `@capra/theme/fonts.css` 发布独立的字体面声明.

**说明**: 不导入 `@capra/theme/base.css` 与 `@capra/theme/fonts.css` 或者说 `@capra/theme/styles.css`。 。 。 . `base.css` 已包含已曝光的符号样式 `styles.css` 和所声明的字体 `fonts.css`。 。 。 .

## 许可证

这个软件包是专有软件. 见 [LICENSE.txt (英语)](https://npmcn.com/package/%40capra/theme/LICENSE.txt)。 。 。 .

## 常见问题

### @capra/theme 是什么？

卡普拉设计系统的主题资源

### 如何安装 @capra/theme？

在项目目录运行 npm install @capra/theme，或使用 pnpm add / yarn add / bun add。

### @capra/theme 支持 TypeScript 吗？

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

### @capra/theme 支持 ESM 还是 CommonJS？

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

### @capra/theme 可以商用吗？

@capra/theme 使用 SEE LICENSE IN LICENSE\.txt 许可。许可条款写在包内的独立文件中，请阅读该文件确认可否商用。以上为概括，不构成法律意见，请以许可原文为准。

### @capra/theme 的下载量有多少？

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

### @capra/theme 还在维护吗？

最新版本 2\.0\.0 发布于 2026/11/07（2 天前）；至今共发布 11 个版本，其中过去 12 个月发布了 11 个；首次发布于 2026/06/17。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

