--- name: radix-ui-design-system type: reference description: "Provides Radix UI patterns for building accessible design systems with headless components, theming, and compound component architecture. Use when building UI with Radix UI primitives or when the user mentions Radix UI, headless components, or accessible component libraries." paths: ["**/*.tsx", "**/*.jsx", "**/components.json"] when_to_use: "When building accessible component libraries with Radix UI primitives, headless components, or design system theming" allowed-tools: Read, Glob, Grep, Write, Edit, Bash user-invocable: true effort: 3 --- # Radix UI Design System ## Critical rules (non-obvious) - **Always use `asChild`** on Trigger/Close — prevents nested ` Title {/* required */} Desc {/* required */} ``` ## Theming: CSS variables (recommended) ```css :root { --color-primary: 220 90% 56%; --radius: 0.5rem; } [data-theme="dark"] { --color-primary: 220 90% 66%; } ``` ```tsx ``` ## Theming: CVA for variants ```tsx import { cva } from 'class-variance-authority'; const button = cva("base-styles", { variants: { variant: { default: "bg-primary", destructive: "bg-red-500" }, size: { sm: "h-9 px-3", md: "h-10 px-4" }, }, defaultVariants: { variant: "default", size: "md" }, }); ``` ## Animation with Framer Motion ```tsx {/* forceMount: critical */} {open && ( )} ``` ## Hook form integration (Select) ```tsx ( US )} /> ``` ## Primitives quick reference | Component | Key parts | |---|---| | Dialog | Root · Trigger · Portal · Overlay · Content · Title · Description · Close | | DropdownMenu | Root · Trigger · Portal · Content · Item · Separator · CheckboxItem · RadioGroup · Sub | | Tabs | Root · List · Trigger · Content | | Tooltip | Provider · Root · Trigger · Portal · Content · Arrow | | Select | Root · Trigger · Value · Icon · Portal · Content · Viewport · Item · ItemText · ItemIndicator | ## shadcn vs raw Radix - **shadcn**: quick prototyping, standard designs; run `npx shadcn@latest add dialog` - **Raw Radix**: full customization, unique designs, zero-dependency component library