关于 fumadocs-component-docs
fumadocs-component-docs 为 8-bit 组件提供文档编写规范,面向维护组件文档的开发者。它涵盖预览、用法示例、导入语句和属性表格。
主要功能
- 01优先展示组件预览
- 02简单与复合组件示例
- 03导入和属性文档规范
- 04使用实际数据展示变体
- 05统一的 TypeScript 代码块
适用场景
- 01编写 8-bit Button 文档
- 02说明包含多个子组件的组件
- 03展示属性变体和示例数据
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ theorcdev/ 8bitcn-ui --skill fumadocs-component-docs安装后在 Claude Code 中输入/fumadocs-component-docs确认已加载。
详细介绍
组件文档模式
按照标准结构,为 8-bit 组件编写全面的文档。
组件预览结构
使用包含真实数据的 ComponentPreview 包装组件示例:
<ComponentPreview title="8-bit ComponentName component" name="component-name">
<div className="md:min-w-[300px] min-w-[200px] flex flex-col gap-8">
<div>
<p className="text-sm text-muted-foreground mb-2">
Description of first variant
</p>
<ComponentName prop={value} />
</div>
<div>
<p className="text-sm text-muted-foreground mb-2">
Description of second variant
</p>
<ComponentName prop={value} variant="retro" />
</div>
</div>
</ComponentPreview>
简单组件示例
对于 Button 等基础组件:
<ComponentPreview title="8-bit button component" name="button">
<Button>Button</Button>
</ComponentPreview>
复杂组件示例
对于 Sheet 等包含多个子组件的组件:
<ComponentPreview title="8-bit Sheet component" name="sheet">
<Sheet>
<SheetTrigger asChild>
<Button variant="outline">Open</Button>
</SheetTrigger>
<SheetContent>
<SheetHeader>
<SheetTitle>Edit profile</SheetTitle>
<SheetDescription className="text-xs">
Make changes to your profile here.
</SheetDescription>
</SheetHeader>
<div className="p-4 flex flex-col gap-4">
<Label>Name</Label>
<Input placeholder="Project name" />
</div>
<SheetFooter className="flex-row-reverse">
<SheetClose asChild>
<Button size="sm">Save changes</Button>
</SheetClose>
</SheetFooter>
</SheetContent>
</Sheet>
</ComponentPreview>
用法部分模式
单个导入(简单组件):
```tsx
import { Button } from "@/components/ui/8bit/button"
**Multiple imports** (complex components):
```mdx
```tsx
import {
Sheet,
SheetContent,
SheetDescription,
SheetHeader,
SheetTitle,
SheetTrigger,
} from "@/components/ui/8bit/sheet"
### Props Documentation
For components with props tables, use tables:
```mdx
### Props
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| variant | `string` | `"default"` | Visual style variant |
| size | `string` | `"default"` | Size of the button |
| asChild | `boolean` | `false` | Whether to merge props onto child |
变体示例
在预览中展示多个变体:
<ComponentPreview title="8-bit Health Bar component" name="health-bar">
<div className="md:min-w-[300px] min-w-[200px] flex flex-col gap-8">
<div>
<p className="text-sm text-muted-foreground mb-2">
Default health bar
</p>
<HealthBar value={75} />
</div>
<div>
<p className="text-sm text-muted-foreground mb-2">
Retro health bar
</p>
<HealthBar value={45} variant="retro" />
</div>
</div>
</ComponentPreview>
复制命令按钮
放置在 ComponentPreview 之前:
<div className="flex flex-col md:flex-row items-center justify-end gap-2 mb-2">
<CopyCommandButton
copyCommand="pnpm dlx shadcn@latest add @8bitcn/component-name"
command="pnpm dlx shadcn@latest add @8bitcn/component-name"
/>
</div>
关键原则
- 先展示预览 - 先展示组件,再进行说明
- 多个变体 - 展示不同的属性组合
- 真实数据 - 在示例中使用有意义的值
- 导入完整 - 包含所有用到的导入项
- 代码块标签 - TypeScript 使用 ```tsx
- 8-bit 组件 - 从
@/components/ui/8bit/导入 - 间距一致 - 使用 gap-4、p-4、mb-2 等模式
参考示例
content/docs/components/button.mdx- 简单组件模式content/docs/components/health-bar.mdx- 变体演示content/docs/components/sheet.mdx- 复杂子组件模式
评论
支持 Markdown