--- name: ui-components license: MIT compatibility: "Claude Code 2.1.148+." description: UI component library patterns for shadcn/ui and Radix Primitives. Use when building accessible component libraries, customizing shadcn components, using Radix unstyled primitives, or creating design system foundations. tags: [ui-components, shadcn, radix, component-library, design-system, accessible-components, react-hook-form, zod, forms, validation, server-actions, field-arrays] context: fork agent: frontend-ui-developer version: 2.1.0 author: OrchestKit user-invocable: false disable-model-invocation: true complexity: medium persuasion-type: reference metadata: category: document-asset-creation allowed-tools: - Read - Glob - Grep - WebFetch - WebSearch --- # UI Components Comprehensive patterns for building accessible UI component libraries with shadcn/ui and Radix Primitives. Covers CVA variants, OKLCH theming, cn() utility, component extension, asChild composition, dialog/menu patterns, and data-attribute styling. Each category has individual rule files in `rules/` loaded on-demand. ## Quick Reference | Category | Rules | Impact | When to Use | |----------|-------|--------|-------------| | [shadcn/ui](#shadcnui) | 4 | HIGH | CVA variants, component customization, form patterns, data tables, v4 styles | | [Radix Primitives](#radix-primitives) | 3 | HIGH | Dialogs, polymorphic composition, data-attribute styling | | [Design System](#design-system) | 5 | HIGH | W3C tokens, OKLCH theming, spacing scales, typography, component states, animation | | [Design System Components](#design-system-components) | 1 | HIGH | Atomic design, CVA variants, accessibility, Storybook | | [Forms](#forms) | 2 | HIGH | React Hook Form v7, Zod validation, Server Actions | | [Modern CSS & Tooling](#modern-css--tooling) | 3 | HIGH | CSS cascade layers, Tailwind v4, Storybook CSF3 | | [UX Foundations](#ux-foundations) | 4 | HIGH | Visual hierarchy, typography thresholds, color system, empty states | **Total: 22 rules across 7 categories** ## Quick Start ```tsx // CVA variant system with cn() utility import { cva, type VariantProps } from 'class-variance-authority' import { cn } from '@/lib/utils' const buttonVariants = cva( 'inline-flex items-center justify-center rounded-md font-medium transition-colors', { variants: { variant: { default: 'bg-primary text-primary-foreground hover:bg-primary/90', destructive: 'bg-destructive text-destructive-foreground', outline: 'border border-input bg-background hover:bg-accent', ghost: 'hover:bg-accent hover:text-accent-foreground', }, size: { default: 'h-10 px-4 py-2', sm: 'h-9 px-3', lg: 'h-11 px-8', }, }, defaultVariants: { variant: 'default', size: 'default' }, } ) ``` ```tsx // Radix Dialog with asChild composition import { Dialog } from 'radix-ui' Title Description Close ``` ## shadcn/ui Beautifully designed, accessible components built on CVA variants, cn() utility, and OKLCH theming. | Rule | File | Key Pattern | |------|------|-------------| | Customization | `rules/shadcn-customization.md` | CVA variants, cn() utility, OKLCH theming, component extension | | Forms | `rules/shadcn-forms.md` | Form field wrappers, react-hook-form integration, validation | | Data Table | `rules/shadcn-data-table.md` | TanStack Table integration, column definitions, sorting/filtering | | v4 Styles | `rules/shadcn-v4-styles.md` | 6 styles (Vega→Luma), preset codes, style detection, class mapping | ### v4 Style System shadcn CLI v4 ships 6 visual styles. Each rewrites component class names — not just CSS variables. | Style | Character | Best For | |-------|-----------|----------| | **Vega** | Balanced radius, clean lines | General purpose (successor to New York) | | **Nova** | Compact padding, reduced margins | Dense dashboards, admin panels | | **Maia** | Soft, rounded, generous spacing | Consumer-facing, friendly apps | | **Lyra** | Sharp, zero radius, monospace pairs | Editorial, developer tools | | **Mira** | Ultra-compact, minimal chrome | Spreadsheets, data-heavy interfaces | | **Luma** | Extreme rounding (`rounded-4xl`), soft elevation (`shadow-md` + ring), breathable layouts | Polished native-app feel, macOS Tahoe-inspired | Configure visually at [ui.shadcn.com/create](https://ui.shadcn.com/create) → pick style, theme, fonts, icons, then copy the generated command. **Do not hardcode preset codes in docs** — they're tied to a specific style snapshot and can drift. ### shadcn CLI v4 (Apr 2026) — new commands | Command | Purpose | |---------|---------| | `npx shadcn@latest apply