@benefex/icons

中文文档
0.51.0发布于 2026/11/06ISCTypeScriptCommonJS零依赖近 30 天下载 7128

Benefex icon package

原始使用文档
文档目录7 节
  1. Adding/Updating icons
  2. Versioning
  3. Usage
  4. Install via npm:
  5. Import icons:
  6. Animated icons
  7. RTL support

onehub-icons

SVGs are automatically converted to TSX using svgr

Adding/Updating icons

  • Add or update the svg in src/svgs
  • Make sure it has fill="currentColor or stroke="currentColor"
  • Make sure it has a viewBox (width, height will be removed)
  • If the icon is directional (it points left or right, such as an arrow, chevron or log-out icon), add data-bfx-rtl="flip" to the root <svg> so it mirrors in RTL. See RTL support.

Versioning

Use semantic versioning:

  • major version when you make incompatible API changes
  • minor version when you add functionality in a backwards-compatible manner
  • patch version when you make backwards-compatible bug fixes

All latest version deployments are handled by semantic-release which is triggered in CircleCI's main pipeline. semantic-release will look at your commit message and determine how to increment the version based on its format. See here for more details on how this works. commitlint hook is used to ensure your commit message is correct before pushing.

To summarise:

  • feat is a minor version bump
  • fix is a patch version bump
  • perf is a patch version bump
  • commit with ! after the type (or scope) is a major version bump. Eg: feat!: add image or feat(new)!: add image
  • all other types do not cause any version bump

*This is fully customizable so can be updated to better suit our needs if required

When the pull request is merged to main, the CircleCI main workflow runs which will perform all of the necessary npm publishing and git tagging, along with creating a Github release containing release notes.

Beta deployments

All pull requests will deploy a beta version as part of the PR pipeline. This allows for easy testing without having to merge your PR. The version deployed will be {CURRENT_MAJOR_VERSION}.0.0-PR${PULL_REQUEST_NUMBER}-BN${BUILD_NUM}. For example: 7.0.0-PR100-BN150

Check the version your branch is using

We do not keep track of the current version in package.json due to it not being necessary (Why isn't it necessary?). However, to print out the package version your branch is using, run npm run check-version

Usage

Install via npm:

pnpm install --save @benefex/icons

Import icons:

You can pass an optional title prop - https://developer.mozilla.org/en-US/docs/Web/SVG/Element/title

import { IconName } from '@benefex/icons';
import { Icon } from '@benefex/components';

<Icon svg={IconName} title="Icon Label" />;

Animated icons

Import the animation stylesheet once, then add bfx-icon--animated to a parent of a supported icon. Currently, the sparkles and upload icons support animation.

import '@benefex/icons/animations.css';
import { SparklesLight } from '@benefex/icons';

<span className="bfx-icon--animated">
  <SparklesLight aria-hidden="true" />
</span>;

RTL support

Directional icons mirror in right-to-left contexts. Import the RTL stylesheet once and they flip whenever they sit inside an element with dir="rtl" (or direction: rtl):

import '@benefex/icons/rtl.css';
import { ArrowRightLight } from '@benefex/icons';

<div dir="rtl">
  <ArrowRightLight aria-hidden="true" />
</div>;

Nothing flips unless the stylesheet is imported.

To opt out for an icon that means a physical direction (for example a map or compass arrow), wrap it in an element with dir="ltr". The icon follows its nearest dir, so only that icon is affected:

<span dir="ltr">
  <ArrowRightLight aria-hidden="true" />
</span>

If you can't add a wrapper, add bfx-icon--rtl-fixed to the icon or any of its parents instead:

<ArrowRightLight className="bfx-icon--rtl-fixed" aria-hidden="true" />

Marking an icon as RTL

Add data-bfx-rtl="flip" to the root <svg> in src/svgs. Only do this when a mirrored copy is the correct RTL icon, i.e. the artwork is a plain mirror image. Don't add it to icons with text, logos, or symbols that read the same way in every language.

The attribute passes through the generator unchanged. Check the result in the Icons/RTL Storybook story.

版本与发布记录

@benefex/icons 共发布 248 个版本,首次发布于 2024/06/06;过去 12 个月发布了 136 个版本。

版本发布日期距今
0.51.0latest2026/11/061 天前
0.0.0-PR126-BN3863beta2026/11/061 天前
0.50.02026/11/044 天前
0.0.0-PR125-BN38442026/11/044 天前
0.49.12026/11/035 天前
0.0.0-PR124-BN38292026/11/035 天前

关于 @benefex/icons 的常见问题

@benefex/icons 是什么?

Benefex icon package

如何安装 @benefex/icons?

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

@benefex/icons 支持 TypeScript 吗?

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

@benefex/icons 支持 ESM 还是 CommonJS?

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

@benefex/icons 可以商用吗?

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

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

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

@benefex/icons 还在维护吗?

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