@carbon/icons

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

Icons for digital and software products using the Carbon Design System

原始使用文档
文档目录8 节
  1. Getting started
  2. Usage
  3. Vanilla
  4. Styling the inner path
  5. Reference
  6. 🙌 Contributing
  7. 📝 License
  8. IBM Telemetry

@carbon/icons

Icons for digital and software products using the Carbon Design System

Getting started

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

npm install -S @carbon/icons

If you prefer Yarn, use the following command instead:

yarn add @carbon/icons

Usage

Icons in Carbon are available directly from @carbon/icons for Vanilla JavaScript. First-party framework packages in this repo are available for:

Additional ecosystem packages are also available for:

In order to use an icon, it may be helpful to reference our Icon library reference page in order to find the specific icon you would like to use.

Vanilla

Once you've found an icon and you're looking to use it in Vanilla JavaScript, you can import the icon by writing the following in your JavaScript file:

import IconName from '@carbon/icons/<module-type>/path-to-icon/size';

For example, if I wanted to import the 16x16 add icon, I would write:

import AddIcon from '@carbon/icons/es/add/16';

In this case, es is used for ES2015 modules (ESM), but one may also use lib for CommonJS or umd for UMD modules.

In order to render this to the screen, we'll make use of our icon-helpers package. This package gives us two options for rendering our icons: toString and toSVG. If rendering in templates, you may want to use the former. If rendering to the DOM, toSVG may be helpful.

In our case, we'll use toSVG to create a node in the DOM for the 16x16 add icon:

import { getAttributes, toSVG } from '@carbon/icon-helpers';
import addIcon from '@carbon/icons/es/add/16';

const addIconNode = toSVG({
  ...addIcon,
  attrs: getAttributes(addIcon.attrs),
});

Styling the inner path

Certain icons in the library support an alternate fill inside of the icon, for example warning--filled supports styling the inner ! path.

In order to style the inner path, you will need to target the SVG using CSS. In general, you can target the path by writing the following:

svg [data-icon-path='inner-path'] {
  fill: blue;
  opacity: 1;
}

In the code snippet above, we are targeting the inner path attribute with [data-icon-path="inner-path"]. The value of fill will be the custom color you would like to set for the inner path. We also need to set opacity to 1 in order to get this inner path to be visible on the page.

Reference

You can view a full reference of our icons here . This is useful for finding the path information in order to import an icon.

🙌 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/icons 共发布 414 个版本,首次发布于 2018/08/31;过去 12 个月发布了 48 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
11.92.0latest2026/11/044 天前
11.92.0-rc.02026/11/035 天前
12.0.0-alpha.3v12-alpha2026/10/2812 天前
12.0.0-alpha.22026/10/2218 天前
11.91.02026/10/2119 天前
11.91.0-rc.02026/10/2020 天前

其他发布通道:alpha → 0.0.1-alpha.32,beta → 0.0.1-beta.5,canary → 10.7.0-alpha.5708,nightly → 10.23.0-alpha.0,v10-next → 10.48.6,v12-alpha → 12.0.0-alpha.3。

关于 @carbon/icons 的常见问题

@carbon/icons 是什么?

Icons for digital and software products using the Carbon Design System

如何安装 @carbon/icons?

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

@carbon/icons 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/carbon__icons 是否存在。

@carbon/icons 支持 ESM 还是 CommonJS?

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

@carbon/icons 可以商用吗?

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

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

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

@carbon/icons 还在维护吗?

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