@fibrae/semi-icons-core

中文文档
0.7.0发布于 2026/11/14MITES Module零依赖构建来源已验证近 30 天下载 2709

Framework-free data and styles of Semi's icons, generated from the SVG sources; full-colour icons under @fibrae/semi-icons-core/lab, illustrations under @fibrae/semi-icons-core/illustrations

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. Subpath entries
  4. Related packages
  5. Adding icons
  6. Adding illustrations
  7. Development

@fibrae/semi-icons-core

简体中文

Framework-agnostic icon and illustration data, plus icon styles, for Semi Design Next. The icon packages (semi-icons-<framework>, illustrations included) of every framework read this data. You can also use it directly to render icons yourself.

Installation

pnpm add @fibrae/semi-icons-core

Ships ESM only, with no peer dependencies.

Usage

Each icon is an ESM module that exports IconData, under the same name as the icon component in each framework:

import { IconActivity } from '@fibrae/semi-icons-core';
import { IconAvatar } from '@fibrae/semi-icons-core/lab'; // color icon that keeps its original colors

IconActivity;
// {
//     name: 'activity', // icon type, rendered as the `semi-icon-activity` class
//     attrs: { viewBox: '0 0 24 24', fill: 'none', xmlns: 'http://www.w3.org/2000/svg' },
//     children: [['path', { 'fill-rule': 'evenodd', 'clip-rule': 'evenodd', d: '...', fill: 'currentColor' }]],
// }
  • A node is [tag, attrs, children?]. Attribute names are DOM names (fill-rule, class, with style as a string), so a framework can pass them through as they are or map them once (React uses fillRule, className and a style object).
  • When rendering, add defaultAttrs to the root svg: width and height of 1em, focusable="false", aria-hidden="true".
  • Multi-color icons (IconAI*Level2, IconAI*Level3, IconAILoading) carry fills, the number of colors supplied through the fill prop. Attribute values contain placeholders: {fillN} is the Nth color of getFillColor(fill, fills), and {uid} is an id unique to each rendered instance. Replace them with resolveValue(value, colors, uid). Other icons pass fill straight to the root svg.

Subpath entries

EntryContents
@fibrae/semi-icons-coreAll IconXxx data, the types IconData and IconNode, and the utilities defaultAttrs, getFillColor and resolveValue
@fibrae/semi-icons-core/labData for color icons that keep their original colors
@fibrae/semi-icons-core/illustrationsIllustration data IllustrationXxx, keeping original colors and a default size of 200
@fibrae/semi-icons-core/styles/icons.scssIcon styles, also available as compiled .css
@fibrae/semi-icons-core/*Other deep paths, such as /utils and /types

The styles define .{prefix}-icon, -extra-small, -small, -default, -large, -extra-large, -spinning and the spin animation, and depend on $prefix from semi:theme. The framework icon packages already import them; import them yourself when using core directly.

  • Depends on no other Semi package.
  • Used by the icon packages of each framework.

Adding icons

  • Monochrome icon: add svgs/icons/<name>.svg and an entry in svgs/icons/meta.json. category is the group name on the icon page and reuses existing values such as Basic, Arrow and Interface; AI icons use One Color, Two Color and Multiple Color by color level. Colors become currentColor.
  • Color icon: add svgs/lab/<name>.svg and an entry in svgs/lab/meta.json. Colors stay as they are.
  • The SVG file name is the icon type, the export name is Icon plus PascalCase (ai_ becomes AI), and the generated module file name is the export name in kebab-case (IconAIBellLevel2 becomes icon-ai-bell-level-2.ts).
  • Do not hand-write {uid} for ids in the SVG source. The generator adds the prefix, and rendering replaces it per instance.
  • Run pnpm build:icon at the repository root. It first writes src/icons, src/lab and src/illustrations in this package (scripts/build-icon.ts, with a fixed svgo config to keep path data stable), then generates the icon and illustration components of each framework. Do not edit generated files by hand.
  • Run pnpm site:dev and open the icon docs page to check the new icon.

Adding illustrations

  • Add svgs/illustrations/<name>.svg, and name the dark variant <name>-dark.svg. Colors, width and height stay as they are, with colors written as var(--semi-color-*).
  • The export name is Illustration plus PascalCase, so noContent-dark becomes IllustrationNoContentDark.
  • Ids also skip the hand-written {uid}. Run pnpm build:icon to generate src/illustrations and the illustration components of each framework.

Development

  • Build: vp pack. For general commands, see CONTRIBUTING.md at the repository root.
  • Tests: __tests__/data.test.ts checks the ids and references of all icons and illustrations.

版本与发布记录

@fibrae/semi-icons-core 共发布 10 个版本,首次发布于 2026/10/28;过去 12 个月发布了 10 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/11/14今天
0.6.02026/11/113 天前
0.5.02026/11/086 天前
0.4.02026/11/077 天前
0.3.12026/11/0410 天前
0.3.02026/11/0212 天前

关于 @fibrae/semi-icons-core 的常见问题

@fibrae/semi-icons-core 是什么?

Framework-free data and styles of Semi's icons, generated from the SVG sources; full-colour icons under @fibrae/semi-icons-core/lab, illustrations under @fibrae/semi-icons-core/illustrations

如何安装 @fibrae/semi-icons-core?

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

@fibrae/semi-icons-core 支持 TypeScript 吗?

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

@fibrae/semi-icons-core 支持 ESM 还是 CommonJS?

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

@fibrae/semi-icons-core 可以商用吗?

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

@fibrae/semi-icons-core 的下载量有多少?

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

@fibrae/semi-icons-core 还在维护吗?

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