@beeq/react

中文文档
1.18.0发布于 2026/11/13Apache-2.0TypeScriptES Module构建来源已验证近 30 天下载 2143

React specific wrapper for BEEQ Design System components

原始使用文档
文档目录4 节
  1. Why is this necessary?
  2. Package installation
  3. Add BEEQ styles and assets
  4. Usage

React Wrapper for BEEQ

A lightweight utility that wraps BEEQ custom elements ("web components") so they can be used like native React components.

Why is this necessary?

React and custom elements don't play nicely together. The problem is best described by Custom Elements Everywhere:

Handling data

React passes all data to Custom Elements in the form of HTML attributes. For primitive data this is fine, but the system breaks down when passing rich data, like objects or arrays. In these instances you end up with stringified values like some-attr="[object Object]" which can't actually be used.

Handling events

Because React implements its own synthetic event system, it cannot listen for DOM events coming from Custom Elements without the use of a workaround. Developers will need to reference their Custom Elements using a ref and manually attach event listeners with addEventListener. This makes working with Custom Elements cumbersome.

This utility solves these problems by exposing a native React component that maps properties and events to the underlying custom element. ✨

Package installation

[!TIP] Please always refer to the official BEEQ documentation for more information about the installation.

  • install the package
npm install @beeq/{core,react}

[!NOTE] Make sure that you have installed the @beeq/core package.

Add BEEQ styles and assets

Import BEEQ styles into your application's main style file:

@import "@beeq/core/dist/beeq/beeq.css";

[!TIP] BEEQ uses SVG icons and these assets are shipped in a separate folder. You can use the setBasePath method to set the path to the icons. Make sure that your project bundle the icons in a way that they are accessible from the browser.

You can move the icons from the node_modules folder to your assets folder and set the path like this:

// vite.config.js
import { defineConfig } from 'vite';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [
    react(),
    viteStaticCopy({
      targets: [
        {
          src: './node_modules/@beeq/core/dist/beeq/svg/*',
          dest: 'icons/svg',
        },
        // add more targets if needed
      ],
    }),
  ],
  // other configurations
});
// main.ts
import { setBasePath } from "@beeq/core/dist/components";

setBasePath('icons/svg');

Please, notice the path 👆

But you can also use a different icons library or a CDN:

import { setBasePath } from "@beeq/core/dist/components";

// Using heroicons library
setBasePath('https://cdn.jsdelivr.net/npm/[email protected]/24/outline');

[!CAUTION] When using a different icons library, make sure you use the correct icon names provided by the library or the CDN.

Usage

import React from 'react';
import { BqButton } from '@beeq/react';

function App() {
  const handleButtonClick = (ev: CustomEvent) => {
    console.log(ev.detail);
  };

  return (
    <BqButton appearance="primary" onBqClick={handleButtonClick}>
      Click Me
    </BqButton>
  );
}

export default App;

版本与发布记录

@beeq/react 共发布 89 个版本,首次发布于 2024/02/21;过去 12 个月发布了 34 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.18.0latest2026/11/13今天
1.18.0-beta.1beta2026/11/13今天
1.18.0-beta.02026/11/13今天
1.18.0-preview.3preview2026/11/13今天
1.18.0-preview.22026/11/121 天前
1.18.0-preview.12026/11/121 天前

关于 @beeq/react 的常见问题

@beeq/react 是什么?

React specific wrapper for BEEQ Design System components

如何安装 @beeq/react?

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

@beeq/react 支持 TypeScript 吗?

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

@beeq/react 支持 ESM 还是 CommonJS?

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

@beeq/react 可以商用吗?

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

@beeq/react 的下载量有多少?

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

@beeq/react 还在维护吗?

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