@builder.io/widgets

中文文档
2.1.3发布于 2026/06/11MITTypeScriptESM + CJS近 30 天下载 8.7万

Adds widgets for Builder.io editing, such as carousels, tabs, accordions, etc.

原始使用文档
文档目录7 节
  1. How to use it
  2. Example
  3. Lazy Loading
  4. With Next.js
  5. Frameworks other than Next.js
  6. More information
  7. Help and troubleshooting

Builder Widgets

Adds widgets for Builder.io editing, such as carousels, tabs, accordions, etc.

How to use it

First, install the package:

npm install @builder.io/widgets

When using the React SDK, import:

import '@builder.io/widgets';

When you import widgets wherever you render a <BuilderComponent ... />, the widgets register and are available in the Visual Editor and when rendering (including server-side).

Example

For a working example, check out Builder's Next.js example.

Lazy Loading

Instead of importing the root @builder.io/widgets, which synchronously registers all components, you can asynchronously import only the widgets used in your Builder content.

With Next.js

To dynamically import widgets in Next.js, use the following import statement:

import '@builder.io/widgets/dist/lib/builder-widgets-async'

Frameworks other than Next.js

Lazy load the widget components explicitly by registering them with your lazy loading library of choice; for example, Loadable, and only the specified components will load when used in content, as needed.

import { Builder } from '@builder.io/react';
import { accordionConfig } from '@builder.io/widgets/dist/lib/components/Accordion.config';
import loadable from '@loadable/component';

Builder.registerComponent(
  loadable(() =>
    import('@builder.io/widgets/dist/lib/components/Accordion').then(mod => mod.AccordionComponent)
  ),
  accordionConfig
);

You can also use this same methodology with Suspense as well.

More information

For more detail, read the official Builder widgets documentation, Using Widgets.

Help and troubleshooting

If you have questions or feedback, contact us at [email protected]. We are happy to help!

版本与发布记录

@builder.io/widgets 共发布 609 个版本,首次发布于 2019/01/22;过去 12 个月发布了 6 个版本。

版本发布日期距今
2.1.3latest2026/06/114 个月前
2.1.22026/06/094 个月前
2.1.2-0dev2026/06/094 个月前
2.1.12026/06/085 个月前
2.1.1-12026/06/055 个月前
2.1.2-12026/05/265 个月前

关于 @builder.io/widgets 的常见问题

@builder.io/widgets 是什么?

Adds widgets for Builder.io editing, such as carousels, tabs, accordions, etc.

如何安装 @builder.io/widgets?

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

@builder.io/widgets 支持 TypeScript 吗?

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

@builder.io/widgets 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@builder.io/widgets 需要什么版本的 Node.js?

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

@builder.io/widgets 可以商用吗?

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

@builder.io/widgets 的下载量有多少?

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

@builder.io/widgets 还在维护吗?

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