install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/shadcn" ~/.claude/skills/comeonoliver-skillshub-shadcn-cddab1 && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/shadcn/SKILL.mdsource content
shadcn/ui Community Best Practices
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.
When to Apply
Reference these guidelines when:
- Installing and configuring shadcn/ui in a project
- 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 | CLI & Project Setup | CRITICAL | |
| 2 | Component Architecture | CRITICAL | |
| 3 | Accessibility Preservation | CRITICAL | |
| 4 | Styling & Theming | HIGH | |
| 5 | Form Patterns | HIGH | |
| 6 | Data Display | MEDIUM-HIGH | |
| 7 | Layout & Navigation | MEDIUM | |
| 8 | Component Composition | MEDIUM | |
| 9 | Performance Optimization | MEDIUM | |
| 10 | State Management | LOW-MEDIUM | |
Quick Reference
1. CLI & Project Setup (CRITICAL)
- Configure components.json before adding componentssetup-components-json
- Configure TypeScript path aliases to match components.jsonsetup-path-aliases
- Create the cn utility before using componentssetup-cn-utility
- Use CLI to add components instead of copy-pastesetup-use-cli-not-copy
- Enable CSS variables for consistent themingsetup-css-variables-theme
- Set RSC flag based on framework supportsetup-rsc-configuration
2. Component Architecture (CRITICAL)
- Use asChild prop for custom trigger elementsarch-use-asChild-for-custom-triggers
- Maintain Radix compound component hierarchyarch-preserve-radix-primitive-structure
- Use Class Variance Authority for type-safe variantsarch-extend-variants-with-cva
- Use cn() utility for safe Tailwind class mergingarch-use-cn-for-class-merging
- Forward refs for form and focus integrationarch-forward-refs-for-composable-components
- Separate base styles from variant-specific stylesarch-isolate-component-variants
3. Accessibility Preservation (CRITICAL)
- Keep Radix ARIA attributes intactally-preserve-aria-attributes
- Add screen reader labels for icon buttonsally-provide-sr-only-labels
- Preserve focus trapping in modalsally-maintain-focus-management
- Keep WAI-ARIA keyboard patternsally-preserve-keyboard-navigation
- Maintain WCAG color contrast ratiosally-ensure-color-contrast
- Always include DialogTitle for screen readersally-dialog-title-required
- Associate labels with form controlsally-form-field-labels
- Use aria-invalid for form error statesally-aria-invalid-errors
- Wrap Checkbox with Label for click targetally-checkbox-label-association
- Preserve focus visible styles for keyboard navigationally-focus-visible-styles
4. Styling & Theming (HIGH)
- Use CSS variables for theme colorsstyle-use-css-variables-for-theming
- Never use !important for style overridesstyle-avoid-important-overrides
- Extend Tailwind theme for design tokensstyle-use-tailwind-theme-extend
- Use consistent Tailwind spacing scalestyle-consistent-spacing-scale
- Apply mobile-first responsive designstyle-responsive-design-patterns
- Support dark mode with CSS variablesstyle-dark-mode-support
5. Form Patterns (HIGH)
- Integrate with React Hook Formform-use-react-hook-form-integration
- Use Zod for type-safe validationform-use-zod-for-schema-validation
- Show errors at appropriate timesform-show-validation-errors-correctly
- Debounce async validation callsform-handle-async-validation
- Reset form state after submissionform-reset-form-state-correctly
6. Data Display (MEDIUM-HIGH)
- Use TanStack Table for sorting/filteringdata-use-tanstack-table-for-complex-tables
- Virtualize lists with 100+ itemsdata-virtualize-large-lists
- Use Skeleton for loading statesdata-use-skeleton-loading-states
- Paginate large datasets server-sidedata-paginate-server-side
- Provide actionable empty statesdata-empty-states-with-guidance
7. Layout & Navigation (MEDIUM)
- Wrap layout with SidebarProviderlayout-sidebar-provider
- Configure sidebar collapsible behaviorlayout-sidebar-collapsible
- Organize sidebar navigation with groupslayout-sidebar-groups
- Use Sheet for mobile navigation overlaylayout-sheet-mobile-nav
- Implement breadcrumbs for deep navigationlayout-breadcrumb-navigation
8. Component Composition (MEDIUM)
- Use compound component patternscomp-compose-with-compound-components
- Use Drawer on mobile devicescomp-use-drawer-for-mobile-modals
- Create searchable selects with Commandcomp-combine-command-with-popover
- Manage nested dialog focus correctlycomp-nest-dialogs-correctly
- Extract reusable form field componentscomp-create-reusable-form-fields
- Use slot pattern for flexible contentcomp-use-slot-pattern-for-flexibility
9. Performance Optimization (MEDIUM)
- Lazy load components over 50KBperf-lazy-load-heavy-components
- Memoize list items and expensive componentsperf-memoize-expensive-renders
- Use direct imports for Lucide iconsperf-optimize-icon-imports
- Isolate form field watchingperf-avoid-unnecessary-rerenders-in-forms
- Debounce search and filter inputsperf-debounce-search-inputs
10. State Management (LOW-MEDIUM)
- Use uncontrolled for simple formsstate-prefer-uncontrolled-for-simple-inputs
- Lift state to lowest common ancestorstate-lift-state-to-appropriate-level
- Control dialogs for programmatic accessstate-use-controlled-dialog-state
- Keep state close to where it's usedstate-colocate-state-with-components
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Full Compiled Document
For a single-file reference containing all rules, see AGENTS.md.
Reference Files
| 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 |