creator-plugins-ui
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreator Plugins UI Library
Creator Plugins UI 库
@lottiefiles/creator-plugins-uisrc/@lottiefiles/creator-plugins-uisrc/Quick Setup
快速设置
Full guide:
references/setup-guide.mdbash
npm install @lottiefiles/creator-plugins-uitypescript
// src/main.tsx — import before local styles
import "@lottiefiles/creator-plugins-ui/styles.css";Components and theme color utility classes (, , , etc.) work with just — no Tailwind configuration needed.
bg-primarytext-foregroundborder-borderstyles.cssIf you need additional custom Tailwind classes beyond what the library provides, set up Tailwind v4:
bash
npm install --save-dev tailwindcss @tailwindcss/viteAdd to plugins, create with , and use for custom colors. Do not create or (v3 patterns). See for full instructions.
tailwindcss()vite.config.tssrc/styles.css@import "tailwindcss"@theme {}tailwind.config.jspostcss.config.jsreferences/setup-guide.md完整指南:
references/setup-guide.mdbash
npm install @lottiefiles/creator-plugins-uitypescript
// src/main.tsx — import before local styles
import "@lottiefiles/creator-plugins-ui/styles.css";组件和主题颜色实用工具类(、、 等)仅需 即可使用——无需配置 Tailwind。
bg-primarytext-foregroundborder-borderstyles.css如果需要库中未提供的额外自定义 Tailwind 类,请配置 Tailwind v4:
bash
npm install --save-dev tailwindcss @tailwindcss/vite在 的 plugins 中添加 ,创建包含 的 ,并使用 定义自定义颜色。不要创建 或 (v3 模式)。完整说明请参阅 。
vite.config.tstailwindcss()@import "tailwindcss"src/styles.css@theme {}tailwind.config.jspostcss.config.jsreferences/setup-guide.mdImport Pattern
导入模式
typescript
import { Button, Input, Select, Slider, cn } from "@lottiefiles/creator-plugins-ui";typescript
import { Button, Input, Select, Slider, cn } from "@lottiefiles/creator-plugins-ui";Available Components
可用组件
For props, variants, and API details, read the TypeScript types from the installed package — they include JSDoc comments, explicit union types, and default values:
node_modules/@lottiefiles/creator-plugins-ui/dist/components/*/Components: 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
Compound components (use sub-component composition): Dialog, Select, Dropdown, Tabs, Card, Tooltip, Toast, RadioGroup
有关 props、variants 和 API 的详细信息,请阅读已安装包中的 TypeScript 类型——其中包含 JSDoc 注释、显式联合类型和默认值:
node_modules/@lottiefiles/creator-plugins-ui/dist/components/*/组件: 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
Compound Component Pattern
复合组件模式
Compound components (Dialog, Select, Dropdown, Tabs) use sub-component composition. Use prop for polymorphic rendering (not — this library uses Base UI, not Radix):
renderasChildtsx
<DialogRoot>
<DialogTrigger render={<Button variant="outline" />}>Delete</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Delete Layer?</DialogTitle>
<DialogDescription>This cannot be undone.</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>Cancel</DialogClose>
<Button variant="destructive" onClick={handleDelete}>Delete</Button>
</DialogFooter>
</DialogContent>
</DialogRoot>复合组件(Dialog、Select、Dropdown、Tabs)采用子组件组合方式。对于多态渲染,请使用 prop(不要使用 ——此库使用 Base UI,而不是 Radix):
renderasChildtsx
<DialogRoot>
<DialogTrigger render={<Button variant="outline" />}>Delete</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Delete Layer?</DialogTitle>
<DialogDescription>This cannot be undone.</DialogDescription>
</DialogHeader>
<DialogFooter>
<DialogClose render={<Button variant="outline" />}>Cancel</DialogClose>
<Button variant="destructive" onClick={handleDelete}>Delete</Button>
</DialogFooter>
</DialogContent>
</DialogRoot>Theming
主题
Full guide:
references/theming-guide.mdDark mode: add to — .
class="dark"<html>document.documentElement.classList.add("dark")Runtime overrides with ThemeProvider:
tsx
<ThemeProvider tokens={{ "--primary": "hsl(260 80% 55%)" }} themeName="custom">
<App />
</ThemeProvider>Key CSS variables: , , , , , , , .
--background--foreground--primary--secondary--destructive--muted-foreground--border--ring完整指南:
references/theming-guide.md暗色模式:将 添加到 ——。
class="dark"<html>document.documentElement.classList.add("dark")通过 ThemeProvider 进行运行时覆盖:
tsx
<ThemeProvider tokens={{ "--primary": "hsl(260 80% 55%)" }} themeName="custom">
<App />
</ThemeProvider>关键 CSS 变量:、、、、、、、。
--background--foreground--primary--secondary--destructive--muted-foreground--border--ringcn() Utility
cn() 工具函数
Use from the library (not a local ) — it includes custom Tailwind merge config for theme colors and font sizes:
cn()clsxtsx
import { cn } from "@lottiefiles/creator-plugins-ui";
<div className={cn("p-4 text-foreground", isActive && "bg-primary")} />请使用库中的 (而不是本地的 )——它包含针对主题颜色和字体大小的自定义 Tailwind merge 配置:
cn()clsxtsx
import { cn } from "@lottiefiles/creator-plugins-ui";
<div className={cn("p-4 text-foreground", isActive && "bg-primary")} />Common Pitfalls
常见陷阱
- Missing import — Components render unstyled. Import
styles.cssonce in entry file.@lottiefiles/creator-plugins-ui/styles.css - Using Tailwind v3 config with v4 — Do not create or
tailwind.config.js. Tailwind v4 usespostcss.config.js+@import "tailwindcss"in CSS and@theme {}for Vite integration.@tailwindcss/vite - Using instead of
asChild— Base UI usesrender, not Radix'srender={<a href="/" />}+asChild.Slot - Select empty string values — is reserved for "no selection". Use
""or similar."none" - NumberInput is controlled only — Requires +
value. No uncontrolled mode.onChange - Slider value is always an array — Pass not
[50]. Callback returns array too.50 - Toast requires provider — throws outside
useToast(). Wrap app root.<ToastProvider> - Dark mode class placement — class goes on
darkor parent, not on the component.<html> - Wrong import — Use
cnfromcn, not a local@lottiefiles/creator-plugins-ui.clsx
- 缺少 导入 — 组件将呈现为无样式状态。在入口文件中导入一次
styles.css。@lottiefiles/creator-plugins-ui/styles.css - 在 v4 中使用 Tailwind v3 配置 — 不要创建 或
tailwind.config.js。Tailwind v4 使用 CSS 中的postcss.config.js+@import "tailwindcss",并通过@theme {}与 Vite 集成。@tailwindcss/vite - 使用 而不是
asChild— Base UI 使用render,而不是 Radix 的render={<a href="/" />}+asChild。Slot - Select 使用空字符串值 — 保留用于“未选择”。请改用
""或类似值。"none" - NumberInput 仅支持受控模式 — 需要 +
value。不支持非受控模式。onChange - Slider 的值始终为数组 — 传入 而不是
[50]。回调也返回数组。50 - Toast 需要 Provider — 在 外部调用
<ToastProvider>会抛出异常。请包裹应用根节点。useToast() - 暗色模式 class 的位置 — class 应放在
dark或父元素上,而不是组件上。<html> - 导入错误的 — 请使用
cn中的@lottiefiles/creator-plugins-ui,而不是本地的cn。clsx
Migration from Custom Components
从自定义组件迁移
Full before/after examples:
references/setup-guide.md- Replace styled components with library components + Tailwind classes
@stitches/react - Replace imports with library components
@radix-ui/* - Replace with
asChildproprender - Replace →
data-[state=checked],data-[checked]→data-[state=open], etc.data-[open] - Replace inline colors with CSS variable classes (,
text-foreground)bg-primary - Replace custom /
cn()with library'sclsx()cn()
完整的迁移前后示例:
references/setup-guide.md- 将 样式组件替换为库组件 + Tailwind 类
@stitches/react - 将 导入替换为库组件
@radix-ui/* - 将 替换为
asChildproprender - 将 →
data-[state=checked],将data-[checked]→data-[state=open],依此类推data-[open] - 将内联颜色替换为 CSS 变量类(、
text-foreground)bg-primary - 将自定义的 /
cn()替换为库中的clsx()cn()
Reference Guide
参考指南
| Reference | Contents |
|---|---|
| Installation, Tailwind config, migration from Stitches/Radix, troubleshooting |
| CSS variables, dark mode, ThemeProvider, custom colors |
| 参考 | 内容 |
|---|---|
| 安装、Tailwind 配置、从 Stitches/Radix 迁移、故障排除 |
| CSS 变量、暗色模式、ThemeProvider、自定义颜色 |