mcpField
W
webflow-code-components

webflow-code-components

github.com/224-industries开发1077 次安装1 周前更新
代码仓库

关于 webflow-code-components

webflow-code-components 是通过 DevLink 构建 React 代码组件并共享至 Webflow 的技能,适用于希望在 Webflow 画布上以可视方式组合交互组件的开发者。

主要功能

  1. 01使用 declareComponent 定义组件
  2. 02通过 Shadow DOM 隔离样式
  3. 03默认启用服务端渲染
  4. 04提供类型化组件属性
  5. 05通过 Webflow CLI 打包和共享库

适用场景

  1. 01为 Webflow 网站发布 React 组件
  2. 02配置可在画布编辑的组件属性
  3. 03构建支持服务端渲染的隔离组件

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/224-industries/webflow-skills --skill webflow-code-components

安装后在 Claude Code 中输入/webflow-code-components确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
bundling-and-import.md
cli.md
component-architecture.md
define-code-component.md
faq.md
frameworks-and-libraries.md
hooks.md
installation.md
introduction.md
prop-types.md
quick-start.md
styling-components.md
references/prop-types/
boolean.md
id.md
image.md
link.md
number.md
rich-text.md
slot.md
text-node.md
text.md
variant.md
visibility.md
scripts/
search_references.py

详细介绍

Webflow 代码组件

使用 DevLink 在 Webflow 中构建、定义并导入 React 代码组件。代码组件让你可以在代码库中开发高级交互式 React 组件,并将其部署到 Webflow,作为共享库供你在画布上进行可视化组合。

快速入门

**前提条件:**使用 Freelancer、Core、Growth、Agency 或 Enterprise 套餐的 Webflow Workspace(或使用 CMS、Business 或 Enterprise 套餐的站点)。Node.js 20+ 和 npm 10+。

  1. 设置项目 — 安装 CLI 和依赖项
  2. 创建 React 组件 — 构建标准 React 组件
  3. 定义代码组件 — 创建包含 declareComponent 的 .webflow.tsx 文件
  4. 导入到 Webflow — 运行 npx webflow library share
  5. 在画布上使用 — 在站点上安装该库,然后拖放组件

完整的端到端教程请参阅 references/quick-start.md。

核心概念

  • Shadow DOM 隔离 — 每个组件的样式和 DOM 都在各自的沙箱中
  • 独立的 React 根节点 — 组件之间不共享 React Context 或状态。请使用 URL 参数、浏览器存储、Nano Stores 或自定义事件
  • 默认启用 SSR — HTML 由服务器渲染,并在客户端完成水合。对于仅限浏览器的组件,可通过 ssr: false 禁用
  • declareComponent — 定义 React 组件在 Webflow 中的显示方式。完整 API 请参阅 references/hooks.md
  • 属性类型 — 提供 11 种类型(Text、Rich Text、Text Node、Link、Image、Number、Boolean、Variant、Visibility、Slot、ID)
  • 打包 — Webflow 使用 Webpack 打包库(最大 50MB)

重要说明

  • **文件名是唯一标识符。**重命名 .webflow.tsx 文件会创建一个新组件并移除旧组件,导致站点上现有的实例失效。
  • 不支持 React Server Components。请仅使用标准 React 组件。
  • 组件可以在客户端获取数据,但 API 必须支持 CORS,并且绝不能将 API 密钥嵌入组件代码中。

参考文档

每个参考文件都包含用于搜索的 YAML frontmatter,其中包含 name、description 和 tags。使用 scripts/search_references.py 中的搜索脚本查找相关参考资料。

入门指南
构建组件
属性类型
打包与命令行
帮助
  • references/faq.md:常见问题 — 设置、样式、导入、故障排查和性能
搜索参考资料
# List all references with metadata
python scripts/search_references.py --list

# Search by tag (exact match)
python scripts/search_references.py --tag <tag>

# Search by keyword (across name, description, tags, and content)
python scripts/search_references.py --search <query>

# Search only prop type references
python scripts/search_references.py --prop-types
python scripts/search_references.py --prop-types --tag <tag>
python scripts/search_references.py --prop-types --search <query>

脚本

  • scripts/search_references.py:按标签或关键词搜索参考文件,或列出所有文件及其元数据

评论

支持 Markdown