@carbon/elements

中文文档
11.101.0发布于 2026/11/04Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 5.6万

A collection of design elements in code for the IBM Design Language

原始使用文档
文档目录7 节
  1. Getting started
  2. Usage
  3. Sass
  4. JavaScript
  5. 🙌 Contributing
  6. 📝 License
  7. IBM Telemetry

@carbon/elements

A collection of design elements in code for the IBM Design Language

Getting started

To install @carbon/elements in your project, you will need to run the following command using npm:

npm install -S @carbon/elements

If you prefer Yarn, use the following command instead:

yarn add @carbon/elements

Usage

@carbon/elements includes all of the other elements packages in the project and can be useful instead of installing each package individually. This package offers support for both the JavaScript exports from these packages, in addition to Sass support.

Sass

@carbon/elements provides two entrypoints for you to leverage: a bundled entrypoint and a module entrypoint. For most use-cases, the bundled entrypoint will work for you. If you have taken an extra step to configure your build configuration to properly resolve @imports from files, then feel free to use the module entrypoint.

To include the bundled entrypoint, you can include the following in your Sass file:

@import '@carbon/elements/scss/elements';

# Import a specific package nested in elements
@import '@carbon/elements/scss/themes/g10';

Include in the example above is how to access nested packages. These packages are ones that you could optionally install as a package, like @carbon/themes, but we've included them inline as a convenience.

To include the module entrypoint, you can include the following in your Sass file:

@import '@carbon/elements/scss/index';

JavaScript

@carbon/elements re-exports the exports from all of the packages that it exports. That means that if an individual package exports a value, then you can import it the same way when using @carbon/elements. For example, with @carbon/colors we might write:

import { colors } from '@carbon/colors';

With @carbon/elements, you can also import colors:

import { colors } from '@carbon/elements';

🙌 Contributing

We're always looking for contributors to help us fix bugs, build new features, or help us improve the project documentation. If you're interested, definitely check out our Contributing Guide! 👀

📝 License

Licensed under the Apache 2.0 License.

IBM Telemetry IBM Telemetry

This package uses IBM Telemetry to collect de-identified and anonymized metrics data. By installing this package as a dependency you are agreeing to telemetry collection. To opt out, see Opting out of IBM Telemetry data collection. For more information on the data being collected, please see the IBM Telemetry documentation.

版本与发布记录

@carbon/elements 共发布 456 个版本,首次发布于 2019/01/11;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
11.101.0latest2026/11/044 天前
11.101.0-rc.02026/11/035 天前
12.0.0-alpha.5v12-alpha2026/10/2812 天前
12.0.0-alpha.42026/10/2218 天前
11.100.02026/10/2119 天前
11.100.0-rc.02026/10/2020 天前

其他发布通道:alpha → 0.0.1-alpha.32,beta → 0.0.1-beta.5,canary → 10.7.0-alpha.5727,nightly → 10.25.0-alpha.0,v10-next → 10.56.7,v12-alpha → 12.0.0-alpha.5。

关于 @carbon/elements 的常见问题

@carbon/elements 是什么?

A collection of design elements in code for the IBM Design Language

如何安装 @carbon/elements?

在项目目录运行 npm install @carbon/elements,或使用 pnpm add / yarn add / bun add。

@carbon/elements 支持 TypeScript 吗?

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

@carbon/elements 支持 ESM 还是 CommonJS?

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

@carbon/elements 可以商用吗?

@carbon/elements 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@carbon/elements 的下载量有多少?

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

@carbon/elements 还在维护吗?

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