npx skills add https://github.com/nuxt/ui --skill contributing为 Nuxt UI 组件库贡献的指南。
src/
├── runtime/
│ ├── components/ # Vue 组件 (PascalCase.vue)
│ ├── composables/ # 组合式函数 (use*.ts)
│ ├── types/ # TypeScript 类型定义
│ └── utils/ # 工具函数
├── theme/ # Tailwind Variants 主题 (kebab-case.ts)
└── module.ts
test/
├── components/ # 组件测试 (*.spec.ts)
│ └── __snapshots__/ # 自动生成的快照
└── component-render.ts
docs/
└── content/docs/2.components/ # 文档 (*.md)
playgrounds/
└── nuxt/app/pages/components/ # 演练场页面
首先链接 CLI(一次性设置):
npm link
然后使用它来创建新组件:
nuxt-ui make component <name> [options]
选项:
--primitive - 基础组件(使用 Reka UI Primitive)--prose - 排版/文本组件广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
--content - 内容组件--template - 仅生成特定模板 (playground, docs, test, theme, component)| 文件 | 主题 |
|---|---|
| references/component-structure.md | Vue 组件文件模式、props/slots/emits 接口、script setup |
| references/theme-structure.md | Tailwind Variants 主题文件、插槽、变体、复合变体 |
| references/testing.md | Vitest 模式、快照测试、无障碍测试 |
| references/documentation.md | 组件文档结构、MDC 语法、示例 |
根据你的任务加载参考文件:
请勿一次性加载所有文件。 仅加载相关文件。
创建新组件时,复制此清单并跟踪进度:
组件: [name]
进度:
- [ ] 1. 使用 CLI 搭建脚手架: nuxt-ui make component <name>
- [ ] 2. 在 src/runtime/components/ 中实现组件
- [ ] 3. 在 src/theme/ 中创建主题
- [ ] 4. 从 src/runtime/types/index.ts 导出类型
- [ ] 5. 在 test/components/ 中编写测试
- [ ] 6. 在 docs/content/docs/2.components/ 中创建文档
- [ ] 7. 添加演练场页面
- [ ] 8. 运行 pnpm run lint
- [ ] 9. 运行 pnpm run typecheck
- [ ] 10. 运行 pnpm run test
审查组件 PR 时,请验证:
PR 审查:
- [ ] 组件遵循现有模式(参见 references/)
- [ ] 主题使用语义化颜色,而非 Tailwind 调色板
- [ ] 测试覆盖了 props、slots 和无障碍性
- [ ] 文档包含用法、示例和 API 部分
- [ ] 符合约定式提交消息格式
- [ ] 所有检查通过(lint, typecheck, test)
| 约定 | 描述 |
|---|---|
| 类型导入 | 始终分开:import type { X } 单独一行 |
| Props 默认值 | 运行时使用 withDefaults(),文档使用 JSDoc @defaultValue |
| 模板插槽 | 在所有元素上添加 data-slot="name" 属性 |
| 计算 UI | 始终使用 computed(() => tv(...)) 进行响应式主题化 |
| 主题支持 | 使用 useComponentUI(name, props) 将主题上下文与组件的 ui prop 合并 |
| 语义化颜色 | 使用 text-default、bg-elevated 等 - 切勿使用 Tailwind 调色板 |
| Reka UI props | 使用 reactivePick + useForwardPropsEmits 来转发 props |
| 表单组件 | 使用 useFormField 和 useFieldGroup 组合式函数 |
pnpm run dev:prepare # 生成类型存根(安装后运行)
pnpm run dev # Nuxt 演练场
pnpm run dev:vue # Vue 演练场
pnpm run docs # 文档站点
pnpm run lint # 检查代码规范
pnpm run lint:fix # 修复代码规范
pnpm run typecheck # 类型检查
pnpm run test # 运行测试
每周安装量
334
代码仓库
GitHub 星标数
6.4K
首次出现
2026年2月1日
安全审计
已安装于
codex243
cursor241
claude-code239
opencode234
gemini-cli233
github-copilot232
Guidelines for contributing to the Nuxt UI component library.
src/
├── runtime/
│ ├── components/ # Vue components (PascalCase.vue)
│ ├── composables/ # Composables (use*.ts)
│ ├── types/ # TypeScript types
│ └── utils/ # Utility functions
├── theme/ # Tailwind Variants themes (kebab-case.ts)
└── module.ts
test/
├── components/ # Component tests (*.spec.ts)
│ └── __snapshots__/ # Auto-generated snapshots
└── component-render.ts
docs/
└── content/docs/2.components/ # Documentation (*.md)
playgrounds/
└── nuxt/app/pages/components/ # Playground pages
Link the CLI first (one-time setup):
npm link
Then use it to create new components:
nuxt-ui make component <name> [options]
Options:
--primitive - Primitive component (uses Reka UI Primitive)--prose - Prose/typography component--content - Content component--template - Generate specific template only (playground, docs, test, theme, component)| File | Topics |
|---|---|
| references/component-structure.md | Vue component file patterns, props/slots/emits interfaces, script setup |
| references/theme-structure.md | Tailwind Variants theme files, slots, variants, compoundVariants |
| references/testing.md | Vitest patterns, snapshot testing, accessibility testing |
| references/documentation.md | Component docs structure, MDC syntax, examples |
Load reference files based on your task:
DO NOT load all files at once. Load only what's relevant.
Copy this checklist and track progress when creating a new component:
Component: [name]
Progress:
- [ ] 1. Scaffold with CLI: nuxt-ui make component <name>
- [ ] 2. Implement component in src/runtime/components/
- [ ] 3. Create theme in src/theme/
- [ ] 4. Export types from src/runtime/types/index.ts
- [ ] 5. Write tests in test/components/
- [ ] 6. Create docs in docs/content/docs/2.components/
- [ ] 7. Add playground page
- [ ] 8. Run pnpm run lint
- [ ] 9. Run pnpm run typecheck
- [ ] 10. Run pnpm run test
When reviewing component PRs, verify:
PR Review:
- [ ] Component follows existing patterns (see references/)
- [ ] Theme uses semantic colors, not Tailwind palette
- [ ] Tests cover props, slots, and accessibility
- [ ] Documentation includes Usage, Examples, and API sections
- [ ] Conventional commit message format
- [ ] All checks pass (lint, typecheck, test)
| Convention | Description |
|---|---|
| Type imports | Always separate: import type { X } on its own line |
| Props defaults | Use withDefaults() for runtime, JSDoc @defaultValue for docs |
| Template slots | Add data-slot="name" attributes on all elements |
| Computed ui | Always use computed(() => tv(...)) for reactive theming |
| Theme support | Use useComponentUI(name, props) to merge Theme context with component prop |
pnpm run dev:prepare # Generate type stubs (run after install)
pnpm run dev # Nuxt playground
pnpm run dev:vue # Vue playground
pnpm run docs # Documentation site
pnpm run lint # Check linting
pnpm run lint:fix # Fix linting
pnpm run typecheck # Type checking
pnpm run test # Run tests
Weekly Installs
334
Repository
GitHub Stars
6.4K
First Seen
Feb 1, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex243
cursor241
claude-code239
opencode234
gemini-cli233
github-copilot232
Flutter应用架构设计指南:分层结构、数据层实现与最佳实践
3,000 周安装
Cloudflare Vectorize 完整指南:全球分布式向量数据库,实现语义搜索与RAG应用
326 周安装
写作技能卓越版:AI技能开发模板与SEO优化指南
326 周安装
Claude Code 技能开发指南:创建、管理和优化技能的最佳实践
326 周安装
Swift iOS 通讯录框架开发指南:使用CNContactStore进行联系人增删改查
327 周安装
书籍翻译指南:AI提示工程书籍《The Interactive Book of Prompting》本地化翻译技能
327 周安装
AWS SDK Java v2 RDS 管理教程 - 数据库实例、快照、参数组操作指南
327 周安装
ui| Semantic colors | Use text-default, bg-elevated, etc. - never Tailwind palette |
| Reka UI props | Use reactivePick + useForwardPropsEmits to forward props |
| Form components | Use useFormField and useFieldGroup composables |