@adobe/spectrum-wc-icons

中文文档
2.0.0-beta.7发布于 2026/11/10Apache-2.0TypeScriptES Module近 30 天下载 2015

Spectrum 2 workflow icons as tree-shakeable custom elements and SVG-string functions

原始使用文档
文档目录7 节
  1. Install
  2. Usage
  3. Custom element (any framework, no Lit)
  4. SVG-string function (build-time, SSR, custom composition)
  5. API
  6. Naming
  7. Regenerating

@adobe/spectrum-wc-icons

Spectrum 2 workflow icons for Spectrum Web Components. Public, framework-agnostic icon art delivered two ways:

  • Per-icon custom elements (<swc-icon-star>): drop-in tags that render in any framework with zero ceremony, carrying size, color, and accessibility.
  • Per-icon SVG-string functions (Icon_Star()): the tree-shakeable substrate, usable via innerHTML, React dangerouslySetInnerHTML, Vue v-html, or Lit unsafeSVG.

Neither couples a consumer to Lit. The package depends only on @adobe/spectrum-wc-core (for the shared IconBase).

The art is generated from the Adobe-internal A4U S2 Icon Global Set (Open Source) by this package's workflow generator. See Regenerating and the icon strategy RFC.

Install

yarn add @adobe/spectrum-wc-icons

Usage

Custom element (any framework, no Lit)

Import the per-icon element by subpath; the import registers the tag as a side effect.

import '@adobe/spectrum-wc-icons/swc-icon-star.js';
<swc-icon-star accessible-label="Favorite"></swc-icon-star>
<swc-icon-star accessible-label="Favorite" /> // React 19

Register every icon at once (not tree-shakeable; prefer per-icon imports in apps):

import '@adobe/spectrum-wc-icons/elements.js';

SVG-string function (build-time, SSR, custom composition)

import { Icon_Star } from '@adobe/spectrum-wc-icons/Star.js';

element.innerHTML = Icon_Star();

The package's default export is the barrel of every function, for convenience:

import { Icon_Star, Icon_Folder } from '@adobe/spectrum-wc-icons';

API

Every element extends IconBase from @adobe/spectrum-wc-core:

MemberTypeDefaultNotes
size'xs' | 's' | 'm' | 'l' | 'xl''m'Sizes the box; the single drawing scales to it.
accessible-labelstring''Set: host gets role="img" + aria-label. Empty: host is aria-hidden (decorative).
CSS color<color>inheritedDrives icon color via the currentColor fallback.
CSS --swc-icon-color<color>currentColorAdvanced color override, independent of text color.

Naming

For an A4U logical name <Name> (PascalCase, e.g. Star, AddCircle, 3DAsset):

OutputFormExample (AddCircle)Example (3DAsset)
FunctionIcon_<Name>()Icon_AddCircle()Icon_3DAsset()
Element classIcon<Name>IconAddCircleIcon3DAsset
Element tagswc-icon-<kebab>swc-icon-add-circleswc-icon-3d-asset
Function subpath/<Name>.js/AddCircle.js/3DAsset.js

Regenerating

Icon art and styles are generated, not hand-authored. Run these from the repo root or gen2/packages/icons.

CommandWhat it does
yarn generate:workflow-iconsRegenerates src/*.ts from the raw SVGs in icon-source/, then runs generate:icon-styles
yarn generate:icon-stylesCopies gen2/packages/swc/stylesheets/_lit-styles/icon-base.css to src/stylesheets/icon-base.css
yarn check:icon-stylesFails if the stylesheet copy is out of date (runs first in yarn build)

To refresh the art (Adobe-internal, VPN required), download the S2 Icon Global Set (Open Source) SVGs into icon-source/, then run yarn generate:workflow-icons. The source SVGs are git-ignored; only the generated art in src/ is committed. See the icon source README for the full steps.

src/stylesheets/icon-base.css is a generated copy: edit the swc source, then run yarn generate:icon-styles. See Icon stylesheet.

版本与发布记录

@adobe/spectrum-wc-icons 共发布 16 个版本,首次发布于 2026/09/02;过去 12 个月发布了 16 个版本。

版本发布日期距今
2.0.0-beta.7latest2026/11/10今天
0.0.0-snapshot.20261104103440snapshot2026/11/045 天前
0.0.0-snapshot.202611041020142026/11/045 天前
2.0.0-beta.62026/10/2714 天前
2.0.0-beta.52026/10/1526 天前
2.0.0-beta.42026/09/301 个月前

其他发布通道:next → 2.0.0-next.20260915131013,snapshot-test → 2.0.0-snapshot-test.20260917153929,snapshot → 0.0.0-snapshot.20261104103440。

关于 @adobe/spectrum-wc-icons 的常见问题

@adobe/spectrum-wc-icons 是什么?

Spectrum 2 workflow icons as tree-shakeable custom elements and SVG-string functions

如何安装 @adobe/spectrum-wc-icons?

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

@adobe/spectrum-wc-icons 支持 TypeScript 吗?

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

@adobe/spectrum-wc-icons 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@adobe/spectrum-wc-icons 可以商用吗?

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

@adobe/spectrum-wc-icons 的下载量有多少?

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

@adobe/spectrum-wc-icons 还在维护吗?

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