SuperAPI AI 工具集

creator-plugins-ui

前端与建站

查看项目

更新于 10-16 06:24

技能介绍

用途:在构建或修改 LottieFiles 插件界面时使用 @lottiefiles/creator-plugins-ui,为 src/ 中的 React 组件提供统一、可访问的 UI 组件与主题样式。

主要能力:提供 25 个基于 Base UI、Tailwind CSS 和 CVA 的可访问组件,包括 Button、Input、Label、Select、Slider、NumberInput、DualNumberInput、Checkbox、Toggle、RadioGroup、Tabs、Dialog、Dropdown、Tooltip、SegmentedControl、SearchBar、Toast、Spinner、Separator、Card、Grid、EmptyState、Badge、AIPromptInput、ThemeProvider。其中 Dialog、Select、Dropdown、Tabs、Card、Tooltip、Toast、RadioGroup 为复合组件,需使用子组件组合方式。

使用方式:安装 pnpm add @lottiefiles/creator-plugins-ui,并在入口文件(如 src/main.tsx)中于本地样式之前导入 import "@lottiefiles/creator-plugins-ui/styles.css"。仅使用组件和主题色工具类(bg-primary、text-foreground、border-border 等)时无需配置 Tailwind。如需额外自定义 Tailwind 类,可安装 pnpm add -D tailwindcss @tailwindcss/vite,在 vite.config.ts 中加入 tailwindcss(),创建 src/styles.css 并写入 @import "tailwindcss",用 @theme {} 定义自定义颜色;不要创建 tailwind.config.js 或 postcss.config.js。组件从包中按需导入,例如 import { Button, Input, Select, Slider, cn } from "@lottiefiles/creator-plugins-ui"。

主题与工具:暗色模式在 <html> 上添加 class="dark"。可用 ThemeProvider 在运行时覆盖令牌,如 tokens={{ "--primary": "hsl(260 80% 55%)" }}。关键 CSS 变量包括 --background、--foreground、--primary、--secondary、--destructive、--muted-foreground、--border、--ring。cn() 应使用库导出的版本,而非本地 clsx。

限制与注意:该库仅用于插件 UI 代码,不用于插件沙箱。复合组件使用 render 属性进行多态渲染,而非 Radix 的 asChild。Select 的空字符串 "" 保留为“无选择”,应使用 "none" 等值。NumberInput 仅支持受控模式,需要 value 与 onChange。Slider 的值始终为数组,传 [50] 而非 50。Toast 需要 ToastProvider 包裹应用根节点。暗色类应放在 <html> 或父元素上。缺少 styles.css 导入会导致组件无样式。不要混用 Tailwind v3 配置模式。从自定义组件迁移时,需将 @stitches/react、@radix-ui/、asChild、data-[state=] 等替换为库组件、render 属性与 data-[checked]、data-[open] 等。详细安装、迁移与排错见 references/setup-guide.md,主题细节见 references/theming-guide.md。