mcpField
S
shadcn

shadcn

github.com/pymodel设计与 UI40471 次安装4 周前更新
代码仓库

关于 shadcn

面向 shadcn/ui 应用开发者的实践指南,涵盖组件架构、无障碍、样式、表单和数据展示。应用特定原语的建议前,指南强调先确认项目组件使用 Radix UI 还是 Base UI。

主要功能

  1. 018 类优先级规则
  2. 02Radix UI 与 Base UI 指南
  3. 03无障碍实践
  4. 04样式与主题建议
  5. 05表单和数据展示模式

适用场景

  1. 01构建或组合 shadcn/ui 组件
  2. 02审查无障碍与样式
  3. 03实现表单和数据展示

MCP 相关

指南包含一条规则,建议使用当前 CLI 管理组件生命周期、注册表和 MCP。

安装

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

$npx skills add https://github.com/pymodel/react-frontend-skills --skill shadcn

安装后在 Claude Code 中输入/shadcn确认已加载。

包含的文件

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

references/
ally-ensure-color-contrast.md
ally-maintain-focus-management.md
ally-preserve-aria-attributes.md
ally-preserve-keyboard-navigation.md
ally-provide-sr-only-labels.md
arch-current-cli-registry.md
arch-extend-variants-with-cva.md
arch-forward-refs-for-composable-components.md
arch-isolate-component-variants.md
arch-preserve-radix-primitive-structure.md
arch-unified-radix-package.md
arch-use-asChild-for-custom-triggers.md
arch-use-cn-for-class-merging.md
comp-combine-command-with-popover.md
comp-compose-with-compound-components.md
comp-create-reusable-form-fields.md
comp-nest-dialogs-correctly.md
comp-use-drawer-for-mobile-modals.md
comp-use-slot-pattern-for-flexibility.md
data-empty-states-with-guidance.md
data-paginate-server-side.md
data-use-skeleton-loading-states.md
data-use-tanstack-table-for-complex-tables.md
data-virtualize-large-lists.md
form-handle-async-validation.md
form-reset-form-state-correctly.md
form-show-validation-errors-correctly.md
form-use-react-hook-form-integration.md
form-use-zod-for-schema-validation.md
perf-avoid-unnecessary-rerenders-in-forms.md

详细介绍

shadcn/ui 社区最佳实践

面向 shadcn/ui 应用的最新最佳实践指南。在应用针对特定基元的指导前,请检查已提交到代码库的组件使用的是 Radix UI 还是 Base UI;当前 shadcn 同时支持两者(新项目默认使用 Base UI),且它们的组合 API 有所不同。组件的安装和升级需通过当前 CLI(v4)进行,它可以解析带命名空间的注册表。

适用场景

在以下情况下参考这些指南:

  • 编写新的 shadcn/ui 组件或组合基元
  • 使用 React Hook Form 和 Zod 验证实现表单
  • 构建数据表格或处理大型数据集的展示
  • 自定义主题或添加深色模式支持
  • 审查代码是否符合无障碍要求

按优先级划分的规则类别

优先级类别影响前缀
1组件架构严重arch-
2保持无障碍性严重ally-
3样式与主题高style-
4表单模式高form-
5数据展示中高data-
6组件组合中comp-
7性能优化中perf-
8状态管理低至中state-

快速参考

1. 组件架构(严重)
2. 保持无障碍性(严重)
3. 样式与主题(高)
4. 表单模式(高)
5. 数据展示(中高)
6. 组件组合(中)
7. 性能优化(中)
8. 状态管理(低中)

使用方法

先在项目根目录运行:

npx -y @pymodel/react-frontend-skills detect  # installed vs. targeted versions

对于上述与任务相关的规则,请阅读 references/<rule-id>.md:了解其重要性,以及错误与正确的代码示例。

评论

支持 Markdown