@bitgo-forks/cryptocurrency-icons

中文文档
0.160.0发布于 2026/11/03CC0-1.0TypeScriptCommonJS零依赖近 30 天下载 5.8万

A set of icons for all the main cryptocurrencies and altcoins, in a range of styles and sizes

原始使用文档
文档目录16 节
  1. Install
  2. Usage
  3. SVG Icons
  4. React Components
  5. PNG Icons
  6. Manifest
  7. Adding New Icons
  8. Adding PNG-Only Icons
  9. SVG Requirements
  10. Scripts
  11. Storybook (PR previews)
  12. Testing
  13. Repository Structure
  14. Contributing
  15. Maintainers
  16. License

Cryptocurrency Icons

BitGo fork of cryptocurrency-icons for generating SVG icons and React components used in BitGo applications.

Install

npm install @bitgo-forks/cryptocurrency-icons

Usage

SVG Icons

Import SVG files directly from the package:

// Color icons (recommended)
import btcIcon from '@bitgo-forks/cryptocurrency-icons/svg/color/btc.svg';

// Monochrome variants
import btcWhite from '@bitgo-forks/cryptocurrency-icons/svg/white/btc.svg';
import btcBlack from '@bitgo-forks/cryptocurrency-icons/svg/black/btc.svg';
import btcOutline from '@bitgo-forks/cryptocurrency-icons/svg/icon/btc.svg';

React Components

Import and use React components with the prefixId prop for ID namespacing:

import BtcIcon from '@bitgo-forks/cryptocurrency-icons/react/btc';

function MyComponent() {
  return (
    <BtcIcon 
      prefixId="unique-id" 
      width={32} 
      height={32} 
    />
  );
}

The prefixId prop prevents CSS/ID collisions when rendering multiple icons on the same page.

PNG Icons

Pre-rendered PNG icons are available in multiple sizes:

  • 32/ - 32x32 pixels
  • 32@2x/ - 64x64 pixels (retina)
  • 128/ - 128x128 pixels

These legacy paths remain available for existing consumers. New raster-only icons that do not have an SVG representation use the explicit png/ path:

import faiIcon from '@bitgo-forks/cryptocurrency-icons/png/128/color/baseethfai.png';

Raster-only identities are declared with formats: ["png"] in manifest.json. They are not generated as SVG or React components. Runtime consumers should use the PNG CDN metadata rather than assuming every manifest entry has an SVG.

Manifest

The manifest.json file contains metadata for all icons:

{
  "symbol": "BTC",
  "name": "Bitcoin",
  "color": "#f7931a",
  "formats": ["svg"]
}

Use this for programmatic access to icon metadata, colors, display names, and available representations. Existing vector icons use formats: ["svg"]; raster-only exceptions use formats: ["png"].

Adding New Icons

  1. Add your SVG to the svg/color/ directory (lowercase filename)
  2. Add the symbol to manifest.json
  3. Run the generation scripts:
npm install
npm run manifest
npm run generate
  1. Commit both the SVG and generated React component

Adding PNG-Only Icons

Use this workflow for artwork that is not suitable for faithful vectorization. PNG-only icons are an additive format and do not create an SVG or generated React component.

  1. Add the approved PNG outputs under png/:
    png/128/color/{symbol}.png
    png/32/color/{symbol}.png
    png/32@2x/color/{symbol}@2x.png
    
  2. Add formats: ["png"] to the icon's manifest.json record.
  3. Run:
    npm run manifest
    npm run cdn-manifest
    npm run sync-check
    npm run test:pack
    
  4. Review the icon in both light and dark consumer contexts.

Do not add a PNG-only identity to svg/color/, react/, or the generated SVG React barrel. SVG-only consumers will use their normal generic fallback; raster-aware consumers use the PNG CDN metadata or the png/* package path.

The cdn-manifest.json file is generated and ignored in source control. It contains the existing SVG variant maps plus an optional png namespace for hashed PNG assets.

SVG Requirements

  • Maximum file size: 100KB (recommended: <20KB)
  • Format: Proper vector SVG (no embedded PNG/JPEG base64 data)
  • ViewBox: Must include viewBox attribute
  • Class names: Avoid generic names like cls-1 or st0 (will be auto-prefixed)

See CONTRIBUTING.md for detailed guidelines.

Scripts

ScriptDescription
npm run generateGenerate React components from SVGs
npm run manifestUpdate manifest.json with coin names and colors
npm run cdn-manifestGenerate hashed SVG/PNG CDN assets and metadata
npm run cleanOptimize SVGs with svgo
npm run validateCheck SVG sizes and detect embedded images
npm run sync-checkVerify SVG/React/manifest parity
npm run test:packVerify published package contents and exports
npm run preflightRun all validation before committing
npm run storybookDev server for icon gallery / previews (port 6006)
npm run build-storybookStatic Storybook build → storybook-static/
npm run test:storybookGallery unit tests + static Storybook build (smoke)

Storybook (PR previews)

PRs that touch icons or Storybook run Storybook PR preview in GitHub Actions: changed SVG paths are written to stories/changed-icons.json, then a static build is synced to the dev automated-test-reports bucket under cryptocurrency-icons-ci/pr-<number>/ (same pattern as Playwright reports; not production cdn.bitgo.com). See WEB-718 / CE-9917.

Locally:

npm install
npm run storybook
# or verify a production build:
npm run test:storybook

Testing

npm test runs SVG validation, sync checks, CDN pack checks, and Storybook gallery logic unit tests (scripts/test-storybook-gallery-logic.mjs). Those tests cover manifest filename normalization, manifest lookup, and matching PR changed paths to svg/<variant>/<file>.svg (same rules as stories/helpers.ts, implemented in scripts/storybook-gallery-logic.mjs).

For Storybook UI and bundling, run npm run test:storybook (runs the gallery tests plus build-storybook). See TESTING.md for the broader validation and release checklist.

Repository Structure

cryptocurrency-icons/
├── svg/
│   ├── color/      # Full-color icons (primary)
│   ├── white/      # White monochrome
│   ├── black/      # Black monochrome
│   └── icon/       # Outline icons
├── react/          # Generated React components
├── 32/             # 32px PNG exports
├── 32@2x/          # 64px PNG exports (retina)
├── 128/            # 128px PNG exports
├── png/            # New PNG-only icon outputs
├── manifest.json   # Icon metadata, including optional formats
├── .storybook/     # Storybook config (dev + PR preview builds)
├── stories/        # Storybook stories + `changed-icons.json` (CI-filled on PRs)
└── scripts/        # Generation, validation, and tests

Contributing

See CONTRIBUTING.md for submission guidelines.

Maintainers

See MAINTAINING.md for maintainer workflows.

License

CC0-1.0 - Public Domain

版本与发布记录

@bitgo-forks/cryptocurrency-icons 共发布 159 个版本,首次发布于 2025/09/16;过去 12 个月发布了 138 个版本。

版本发布日期距今
0.160.0latest2026/11/035 天前
0.159.02026/10/2810 天前
0.158.12026/10/2217 天前
0.158.02026/10/081 个月前
0.157.02026/10/011 个月前
0.156.02026/09/301 个月前

其他发布通道:seed → 0.0.0-seed.0。

关于 @bitgo-forks/cryptocurrency-icons 的常见问题

@bitgo-forks/cryptocurrency-icons 是什么?

A set of icons for all the main cryptocurrencies and altcoins, in a range of styles and sizes

如何安装 @bitgo-forks/cryptocurrency-icons?

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

@bitgo-forks/cryptocurrency-icons 支持 TypeScript 吗?

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

@bitgo-forks/cryptocurrency-icons 支持 ESM 还是 CommonJS?

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

@bitgo-forks/cryptocurrency-icons 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@bitgo-forks/cryptocurrency-icons 可以商用吗?

@bitgo-forks/cryptocurrency-icons 使用 CC0-1.0 许可。作者放弃著作权,可不受限制地使用。以上为概括,不构成法律意见,请以许可原文为准。

@bitgo-forks/cryptocurrency-icons 的下载量有多少?

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

@bitgo-forks/cryptocurrency-icons 还在维护吗?

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