@carbon/pictograms-react

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

React components for pictograms in digital and software products using the Carbon Design System

原始使用文档
文档目录7 节
  1. Getting started
  2. Usage
  3. Icon fill
  4. Focus and aria-label
  5. 🙌 Contributing
  6. 📝 License
  7. IBM Telemetry

@carbon/pictograms-react

React components for pictograms in digital and software products using the Carbon Design System

Getting started

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

npm install -S @carbon/pictograms-react

If you prefer Yarn, use the following command instead:

yarn add @carbon/pictograms-react

Usage

You can import a pictogram component into your project by referring to its name:

import { Airplane } from '@carbon/pictograms-react';

We also provide CommonJS and UMD files in the lib and umd directories, respectively.

To import using CommonJS, you can do the following:

const { Airplane } = require('@carbon/pictograms-react');

Note: if you would like to find the import path for a pictogram, you can reference our Pictogram Library

Icon fill

All icons from the library support being styled by the fill property. You can change the color of an icon by passing in a custom class name that sets this property (preferred), or by passing in an inline style. For example:

// CSS custom class name to set the fill of the icon to `rebeccapurple`
svg.my-custom-class {
  fill: rebeccapurple;
}
import { Airplane } from '@carbon/pictograms-react';

function MyComponent() {
  return (
    <button>
      <Airplane aria-label="Add" className="my-custom-class" />
    </button>
  );
}

Focus and aria-label

By default, the icon components from @carbon/pictograms-react are treated as decorative content. This means that we set aria-hidden="true" unless certain props are passed to the component.

If you would like the icon to be announced by a screen reader, you can supply an aria-label or aria-labelledby. For example:

import { Airplane } from '@carbon/pictograms-react';

function MyComponent() {
  return (
    <button>
      <Airplane aria-label="Add" />
    </button>
  );
}

Doing this will add the appropriate role to the <svg> node, as well.

If you would like the <svg> to receive focus, you will need to pass in a tabIndex value. For example:

import { Airplane } from '@carbon/pictograms-react';

function MyComponent() {
  return <Airplane aria-label="Add" tabIndex="0" />;
}

Including tabIndex and aria-label (or aria-labelledby) will set the corresponding tabindex on the underlying <svg> and verify support in older browsers like Internet Explorer 11 by setting focusable to true.

🙌 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/pictograms-react 共发布 314 个版本,首次发布于 2019/09/26;过去 12 个月发布了 54 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
11.114.0latest2026/11/044 天前
11.114.0-rc.0next2026/11/035 天前
12.0.0-alpha.3v12-alpha2026/10/2812 天前
12.0.0-alpha.22026/10/2218 天前
11.113.02026/10/2119 天前
11.113.0-rc.02026/10/2020 天前

其他发布通道:alpha → 10.6.0-alpha.2,nightly → 11.1.0-alpha.0,v10-next → 11.25.6,v12-alpha → 12.0.0-alpha.3,next → 11.114.0-rc.0。

关于 @carbon/pictograms-react 的常见问题

@carbon/pictograms-react 是什么?

React components for pictograms in digital and software products using the Carbon Design System

如何安装 @carbon/pictograms-react?

在项目目录运行 npm install @carbon/pictograms-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@carbon/pictograms-react 支持 TypeScript 吗?

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

@carbon/pictograms-react 支持 ESM 还是 CommonJS?

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

@carbon/pictograms-react 可以商用吗?

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

@carbon/pictograms-react 的下载量有多少?

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

@carbon/pictograms-react 还在维护吗?

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