@cockroachlabs/icons

中文文档
0.9.12发布于 2026/07/28MITTypeScriptCommonJS近 30 天下载 1.6万

Icons for Cockroach UI exported as React Components

原始使用文档
文档目录4 节
  1. Usage
  2. Icon sets and components
  3. SVG prop pass through
  4. How do I contribute new icons?

@cockroachlabs/icons

a package containing Cockroach Labs icons as SVG for consumption by other components

This package serves as a store for SVG icons that are converted and published as React components.

Usage

While any icon in the collection of this package can be imported individually, in practice, for use in Cockroach Labs applications a number of components are exported from ui-components that provide types for intended Icon usages (sizes and fills). See below for examples.

import { Time } from "@cockroachlabs/icons";

const TimeButton = ({ timestamp }) => (
  <button>
    <Time /> {timestamp}
  </button>
);
import * as Icons from "@cockroachlabs/icons";

// ...

<EditMessage icon={Icons.Pencil} />;

Each Icon component will render an <svg /> element with an unbounded size and may not have a default fill color. These properties can be passed in as props.


  import { CheckCircleFilled } from "@cockroachlabs/icons";

  <CheckCircleFilled fill="green" height="24px" width="24px" />

  // or

  <CheckCircleFilled style={{ fill: "green", height: "24px", width: "24px" }} />

Icon sets and components

Icons with common attributes are grouped together into an exported collection, and generally have an associated component to render an icon from the set. The exported sets are,

  • System Icons - Used as visual representations of common actions and commands to provide additional context and enhance usability. These icons can be scaled up or down in size if necessary. They should only be used as 1 color.
  • Pictograms - Pictogram icons contain more than 1 color value and are larger in size than system icons. They are used to add personality, visual interest and branding into the UI where space is available.
  • Third Party Icons - Used to represent 3rd party logos within the UI. These icons can be scaled up or down in size if necessary and inherit the 3rd party brand colors.
  • Credit Cards - Credit card icons are used to represent credit card brands. They can be scaled up or down and can consist of colors outside our design system palette.
  • Flags - Flag icons are used to represent a region or country. They can be scaled up or down and can consist of colors outside our design system palette.
  • Illustrations - Illustrations are used at a large scale, typically in areas with a lot of space like empty states or 404 pages. They add personality, visual interest and branding into the UI.

These sets can be rendered using their associated component,

import { Icon, Pictogram, ThirdPartyIcon, CreditCard, Flag, Illustration } from "@cockroachlabs/ui-components";

/*
   ...snip
*/

<Icon iconName="Gear" size="small" fill="info" />

<Pictogram pictogramName="Email" size="medium" />

<ThirdParty iconName="Gcp" size="large" />

{/* Flag icons can be referenced by "flagName" or "countryCode" prop  */}
<Flag flagName="Canada" size="medium" />
<Flag countryCode="can" size="small" />

<CreditCard creditCardName="Visa" size="tiny" />

<Illustration illustrationName="SleepMoon" />

SVG prop pass through

The components that render icons all extend SVGElement props and so any component can take common HTML element attributes. For example,

  <Icon iconName="Pencil" size="small" className="edit-icon" aria-label="Edit field icon" id="edit-icon">

How do I contribute new icons?

See CONTRIBUTING.md for instructions on adding new icons and publishing new versions of the icons package.

版本与发布记录

@cockroachlabs/icons 共发布 983 个版本,首次发布于 2020/02/20;过去 12 个月发布了 7 个版本。

版本发布日期距今
0.9.12latest2026/07/283 个月前
0.9.112026/05/145 个月前
0.9.102026/04/166 个月前
0.9.92026/04/156 个月前
0.9.82026/04/146 个月前
0.9.72026/04/027 个月前

其他发布通道:canary → 0.7.14-canary.508.12922023130.0。

关于 @cockroachlabs/icons 的常见问题

@cockroachlabs/icons 是什么?

Icons for Cockroach UI exported as React Components

如何安装 @cockroachlabs/icons?

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

@cockroachlabs/icons 支持 TypeScript 吗?

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

@cockroachlabs/icons 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@cockroachlabs/icons 可以商用吗?

@cockroachlabs/icons 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

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

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

@cockroachlabs/icons 还在维护吗?

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