npx skills add https://github.com/pproenca/dot-skills --skill shadcn由 shadcn/ui 社区维护的 shadcn/ui 应用程序综合最佳实践指南。包含 10 个类别下的 58 条规则,按影响优先级排序,以指导自动化重构和代码生成。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | CLI 与项目设置 | 关键 | setup- |
| 2 | 组件架构 | 关键 | arch- |
| 3 | 无障碍访问保护 | 关键 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
ally- |
| 4 | 样式与主题 | 高 | style- |
| 5 | 表单模式 | 高 | form- |
| 6 | 数据显示 | 中高 | data- |
| 7 | 布局与导航 | 中 | layout- |
| 8 | 组件组合 | 中 | comp- |
| 9 | 性能优化 | 中 | perf- |
| 10 | 状态管理 | 低中 | state- |
setup-components-json - 在添加组件前配置 components.jsonsetup-path-aliases - 配置 TypeScript 路径别名以匹配 components.jsonsetup-cn-utility - 在使用组件前创建 cn 工具函数setup-use-cli-not-copy - 使用 CLI 添加组件而非复制粘贴setup-css-variables-theme - 启用 CSS 变量以实现一致的主题化setup-rsc-configuration - 根据框架支持情况设置 RSC 标志arch-use-asChild-for-custom-triggers - 为自定义触发器元素使用 asChild 属性arch-preserve-radix-primitive-structure - 保持 Radix 复合组件层次结构arch-extend-variants-with-cva - 使用 Class Variance Authority 实现类型安全的变体arch-use-cn-for-class-merging - 使用 cn() 工具函数安全地合并 Tailwind 类arch-forward-refs-for-composable-components - 为表单和焦点集成转发 refsarch-isolate-component-variants - 将基础样式与变体特定样式分离ally-preserve-aria-attributes - 保持 Radix ARIA 属性完整ally-provide-sr-only-labels - 为图标按钮添加屏幕阅读器标签ally-maintain-focus-management - 在模态框中保持焦点捕获ally-preserve-keyboard-navigation - 保持 WAI-ARIA 键盘导航模式ally-ensure-color-contrast - 保持 WCAG 颜色对比度比率ally-dialog-title-required - 始终为屏幕阅读器包含 DialogTitleally-form-field-labels - 将标签与表单控件关联ally-aria-invalid-errors - 使用 aria-invalid 表示表单错误状态ally-checkbox-label-association - 用 Label 包裹 Checkbox 以提供点击目标ally-focus-visible-styles - 为键盘导航保留焦点可见样式style-use-css-variables-for-theming - 使用 CSS 变量定义主题颜色style-avoid-important-overrides - 切勿使用 !important 进行样式覆盖style-use-tailwind-theme-extend - 扩展 Tailwind 主题以定义设计令牌style-consistent-spacing-scale - 使用一致的 Tailwind 间距比例style-responsive-design-patterns - 应用移动优先的响应式设计style-dark-mode-support - 使用 CSS 变量支持深色模式form-use-react-hook-form-integration - 与 React Hook Form 集成form-use-zod-for-schema-validation - 使用 Zod 进行类型安全的验证form-show-validation-errors-correctly - 在适当时机显示错误form-handle-async-validation - 对异步验证调用进行防抖处理form-reset-form-state-correctly - 提交后正确重置表单状态data-use-tanstack-table-for-complex-tables - 使用 TanStack Table 进行排序/筛选data-virtualize-large-lists - 对超过 100 项的列表进行虚拟化data-use-skeleton-loading-states - 使用 Skeleton 组件表示加载状态data-paginate-server-side - 在服务器端对大型数据集进行分页data-empty-states-with-guidance - 提供可操作的空白状态layout-sidebar-provider - 使用 SidebarProvider 包裹布局layout-sidebar-collapsible - 配置侧边栏可折叠行为layout-sidebar-groups - 使用分组组织侧边栏导航layout-sheet-mobile-nav - 使用 Sheet 组件实现移动端导航覆盖层layout-breadcrumb-navigation - 为深层导航实现面包屑导航comp-compose-with-compound-components - 使用复合组件模式comp-use-drawer-for-mobile-modals - 在移动设备上使用 Drawer 组件comp-combine-command-with-popover - 使用 Command 组件创建可搜索的选择器comp-nest-dialogs-correctly - 正确管理嵌套对话框的焦点comp-create-reusable-form-fields - 提取可复用的表单字段组件comp-use-slot-pattern-for-flexibility - 使用插槽模式实现灵活的内容布局perf-lazy-load-heavy-components - 对超过 50KB 的组件进行懒加载perf-memoize-expensive-renders - 对列表项和开销大的组件进行记忆化perf-optimize-icon-imports - 对 Lucide 图标使用直接导入perf-avoid-unnecessary-rerenders-in-forms - 隔离表单字段的监听perf-debounce-search-inputs - 对搜索和筛选输入进行防抖处理state-prefer-uncontrolled-for-simple-inputs - 对简单表单使用非受控模式state-lift-state-to-appropriate-level - 将状态提升到最低公共祖先state-use-controlled-dialog-state - 控制对话框状态以实现编程式访问state-colocate-state-with-components - 将状态保持在离使用位置最近的地方阅读单独的参考文件以获取详细解释和代码示例:
如需包含所有规则的单一文件参考,请参阅 AGENTS.md。
| 文件 | 描述 |
|---|---|
| AGENTS.md | 包含所有规则的完整编译指南 |
| references/_sections.md | 类别定义和排序 |
| assets/templates/_template.md | 新规则模板 |
| metadata.json | 版本和参考信息 |
每周安装次数
356
代码仓库
GitHub 星标数
85
首次出现
2026年1月22日
安全审计
已安装于
opencode315
gemini-cli295
codex291
github-copilot271
claude-code271
cursor261
Comprehensive best practices guide for shadcn/ui applications, maintained by the shadcn/ui community. Contains 58 rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | CLI & Project Setup | CRITICAL | setup- |
| 2 | Component Architecture | CRITICAL | arch- |
| 3 | Accessibility Preservation | CRITICAL | ally- |
| 4 | Styling & Theming | HIGH | style- |
| 5 | Form Patterns | HIGH | form- |
| 6 | Data Display | MEDIUM-HIGH | data- |
| 7 | Layout & Navigation | MEDIUM | layout- |
| 8 | Component Composition | MEDIUM | comp- |
| 9 | Performance Optimization | MEDIUM | perf- |
| 10 | State Management | LOW-MEDIUM | state- |
setup-components-json - Configure components.json before adding componentssetup-path-aliases - Configure TypeScript path aliases to match components.jsonsetup-cn-utility - Create the cn utility before using componentssetup-use-cli-not-copy - Use CLI to add components instead of copy-pastesetup-css-variables-theme - Enable CSS variables for consistent themingarch-use-asChild-for-custom-triggers - Use asChild prop for custom trigger elementsarch-preserve-radix-primitive-structure - Maintain Radix compound component hierarchyarch-extend-variants-with-cva - Use Class Variance Authority for type-safe variantsarch-use-cn-for-class-merging - Use cn() utility for safe Tailwind class mergingarch-forward-refs-for-composable-components - Forward refs for form and focus integrationally-preserve-aria-attributes - Keep Radix ARIA attributes intactally-provide-sr-only-labels - Add screen reader labels for icon buttonsally-maintain-focus-management - Preserve focus trapping in modalsally-preserve-keyboard-navigation - Keep WAI-ARIA keyboard patternsally-ensure-color-contrast - Maintain WCAG color contrast ratiosstyle-use-css-variables-for-theming - Use CSS variables for theme colorsstyle-avoid-important-overrides - Never use !important for style overridesstyle-use-tailwind-theme-extend - Extend Tailwind theme for design tokensstyle-consistent-spacing-scale - Use consistent Tailwind spacing scalestyle-responsive-design-patterns - Apply mobile-first responsive designform-use-react-hook-form-integration - Integrate with React Hook Formform-use-zod-for-schema-validation - Use Zod for type-safe validationform-show-validation-errors-correctly - Show errors at appropriate timesform-handle-async-validation - Debounce async validation callsform-reset-form-state-correctly - Reset form state after submissiondata-use-tanstack-table-for-complex-tables - Use TanStack Table for sorting/filteringdata-virtualize-large-lists - Virtualize lists with 100+ itemsdata-use-skeleton-loading-states - Use Skeleton for loading statesdata-paginate-server-side - Paginate large datasets server-sidedata-empty-states-with-guidance - Provide actionable empty stateslayout-sidebar-provider - Wrap layout with SidebarProviderlayout-sidebar-collapsible - Configure sidebar collapsible behaviorlayout-sidebar-groups - Organize sidebar navigation with groupslayout-sheet-mobile-nav - Use Sheet for mobile navigation overlaylayout-breadcrumb-navigation - Implement breadcrumbs for deep navigationcomp-compose-with-compound-components - Use compound component patternscomp-use-drawer-for-mobile-modals - Use Drawer on mobile devicescomp-combine-command-with-popover - Create searchable selects with Commandcomp-nest-dialogs-correctly - Manage nested dialog focus correctlycomp-create-reusable-form-fields - Extract reusable form field componentsperf-lazy-load-heavy-components - Lazy load components over 50KBperf-memoize-expensive-renders - Memoize list items and expensive componentsperf-optimize-icon-imports - Use direct imports for Lucide iconsperf-avoid-unnecessary-rerenders-in-forms - Isolate form field watchingperf-debounce-search-inputs - Debounce search and filter inputsstate-prefer-uncontrolled-for-simple-inputs - Use uncontrolled for simple formsstate-lift-state-to-appropriate-level - Lift state to lowest common ancestorstate-use-controlled-dialog-state - Control dialogs for programmatic accessstate-colocate-state-with-components - Keep state close to where it's usedRead individual reference files for detailed explanations and code examples:
For a single-file reference containing all rules, see AGENTS.md.
| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |
Weekly Installs
356
Repository
GitHub Stars
85
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode315
gemini-cli295
codex291
github-copilot271
claude-code271
cursor261
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
106,200 周安装
setup-rsc-configurationally-dialog-title-requiredally-form-field-labels - Associate labels with form controlsally-aria-invalid-errors - Use aria-invalid for form error statesally-checkbox-label-association - Wrap Checkbox with Label for click targetally-focus-visible-styles - Preserve focus visible styles for keyboard navigationstyle-dark-mode-supportcomp-use-slot-pattern-for-flexibility