360 Secure SkillHub
360 安全技能中心

shadcn

提供 shadcn/ui(Radix 或 Base UI)前端开发的社区最佳实践,按组件架构、无障碍、样式主题、表单、数据展示、组件组合、性能与状态管理八类规则组织,含规则说明和正误代码对比,并指引用当前 CLI 管理组件安装与升级。

PyModel
热度 0.00
最近更新 2026-10-18 21:48:36
分类:开发依赖:代码执行 / 读写文件应用场景:代码生成 / 代码审查 / UI 原型

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add pymodel/react-frontend-skills/shadcn
Metadata
name
shadcn
description
shadcn/ui components on Radix or Base UI.

shadcn/ui Community Best Practices

Current best-practices guide for shadcn/ui applications. Before applying primitive-specific guidance, inspect whether the checked-in components use Radix UI or Base UI; current shadcn supports both (Base UI is the default for new projects) and their composition APIs differ. Component installs and upgrades go through the current CLI (v4), which resolves namespaced registries.

When to Apply

Reference these guidelines when:

  • Writing new shadcn/ui components or composing primitives
  • Implementing forms with React Hook Form and Zod validation
  • Building data tables or handling large dataset displays
  • Customizing themes or adding dark mode support
  • Reviewing code for accessibility compliance

Rule Categories by Priority

Priority Category Impact Prefix
1 Component Architecture CRITICAL arch-
2 Accessibility Preservation CRITICAL ally-
3 Styling & Theming HIGH style-
4 Form Patterns HIGH form-
5 Data Display MEDIUM-HIGH data-
6 Component Composition MEDIUM comp-
7 Performance Optimization MEDIUM perf-
8 State Management LOW-MEDIUM state-

Quick Reference

1. Component Architecture (CRITICAL)

2. Accessibility Preservation (CRITICAL)

3. Styling & Theming (HIGH)

4. Form Patterns (HIGH)

5. Data Display (MEDIUM-HIGH)

6. Component Composition (MEDIUM)

7. Performance Optimization (MEDIUM)

8. State Management (LOW-MEDIUM)

How to Use

Run in the project root first:

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

Read references/<rule-id>.md for each rule above that matches the task: why it matters, then incorrect vs. correct code.