UI Components
Patterns for building accessible UI component libraries with shadcn/ui and Radix Primitives, as a thin wrap over the first-party docs: quick-start recipes, key decisions, anti-patterns, and the house delta. Vendor mechanics (CVA variants, cn() utility, component extension, asChild composition, dialog/menu patterns, data-attribute styling) are upstream's job; see Upstream coverage (do not restate). Each remaining category has individual rule files in rules/ loaded on-demand.
Quick Reference
| Category |
Rules |
Impact |
When to Use |
| shadcn/ui |
1 |
HIGH |
v4 styles, preset codes, style detection |
| Design System |
4 |
HIGH |
W3C tokens, OKLCH theming, spacing scales, typography, component states, animation |
| Design System Components |
1 |
HIGH |
Atomic design, CVA variants, accessibility, Storybook |
| Forms |
2 |
HIGH |
React Hook Form v7, Zod validation, Server Actions |
| Modern CSS & Tooling |
3 |
HIGH |
CSS cascade layers, Tailwind v4, Storybook CSF3 |
| UX Foundations |
4 |
HIGH |
Visual hierarchy, typography thresholds, color system, empty states |
Total: 15 rules across 6 categories. Radix primitive mechanics and shadcn
customization tutorials are first-party documented; see
Upstream coverage (do not restate) and
references/ork-delta.md for what stays ours.
Quick Start
// 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' },
}
)
// Radix Dialog with asChild composition
import { Dialog } from 'radix-ui'
<Dialog.Root>
<Dialog.Trigger asChild>
<Button>Open</Button>
</Dialog.Trigger>
<Dialog.Portal>
<Dialog.Overlay className="fixed inset-0 bg-black/50" />
<Dialog.Content className="data-[state=open]:animate-in">
<Dialog.Title>Title</Dialog.Title>
<Dialog.Description>Description</Dialog.Description>
<Dialog.Close>Close</Dialog.Close>
</Dialog.Content>
</Dialog.Portal>
</Dialog.Root>
shadcn/ui
Beautifully designed, accessible components built on CVA variants, cn() utility, and OKLCH theming.
| Rule |
File |
Key Pattern |
| v4 Styles |
rules/shadcn-v4-styles.md |
6 styles (Vega→Luma), preset codes, style detection, class mapping |
Customization, form, and data-table walkthroughs are upstream's job now; see
Upstream coverage (do not restate). Our
conventions on top of them live in references/ork-delta.md.
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 → 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 <style> |
Apply a published style (e.g. luma, nova, lyra) to the current project — re-skins existing components without re-adding them |
npx shadcn@latest info |
Show resolved config: registry, style, tokens, components present, Tailwind version |
npx shadcn@latest skills |
List the shadcn/skills registry — Claude Code- and Cursor-ready skill packs that bundle CLI commands with agent guidance |
npx shadcn@latest build |
Build a custom registry (already-documented) — pair with apply to ship a private style |
Detection: Read components.json → "style" field (e.g., "radix-luma", "base-nova"). Old "new-york" and "default" styles are superseded by Vega.
Key Decisions
| Decision |
Recommendation |
| Color format |
OKLCH for perceptually uniform theming |
| Class merging |
Always use cn() for Tailwind conflicts |
| Extending components |
Wrap, don't modify source files |
| Variants |
Use CVA for type-safe multi-axis variants |
| Styling approach |
Data attributes + Tailwind arbitrary variants |
| Composition |
Use asChild to avoid wrapper divs |
| Animation |
CSS-only with data-state selectors |
| Form components |
Combine with react-hook-form |
| Destructive confirmations |
AlertDialog, never plain Dialog (see references/ork-delta.md) |
Anti-Patterns (FORBIDDEN)
- Modifying shadcn source: Wrap and extend instead of editing generated files
- Skipping cn(): Direct string concatenation causes Tailwind class conflicts
- Inline styles over CVA: Use CVA for type-safe, reusable variants
- Wrapper divs: Use
asChild to avoid extra DOM elements
- Missing Dialog.Title: Every dialog must have an accessible title
- Positive tabindex: Using
tabindex > 0 disrupts natural tab order
- Color-only states: Use data attributes + multiple indicators
- Manual focus management: Use Radix built-in focus trapping
Upstream coverage (do not restate)
These topics were removed from this skill on 2026-07-31 because a first-party
source owns them. Point sessions at the source; keep only floors, scars, and
house decisions here (they live in references/ork-delta.md).
| Topic |
First-party source |
| shadcn setup, init checklist, adding components |
vercel:shadcn (marketplace skill), https://ui.shadcn.com/docs/installation |
| shadcn customization, CVA variants, cn() utility, component extension |
vercel:shadcn (marketplace skill), https://ui.shadcn.com/docs and https://cva.style/docs |
| OKLCH theming variables, light/dark CSS variable sets |
https://ui.shadcn.com/docs/theming |
| Dark mode toggle with next-themes |
https://ui.shadcn.com/docs/dark-mode and https://github.com/pacocoursey/next-themes |
| Data table with TanStack Table |
https://ui.shadcn.com/docs/components/data-table and https://tanstack.com/table |
| Form field wrappers and validation states |
https://ui.shadcn.com/docs/components/form |
| Radix Dialog and AlertDialog patterns |
https://www.radix-ui.com/primitives/docs/components/dialog and .../components/alert-dialog |
| Radix asChild / Slot composition |
https://www.radix-ui.com/primitives/docs/guides/composition |
| Radix data-attribute styling and focus management |
https://www.radix-ui.com/primitives/docs/guides/styling |
| Dropdown menu, popover, tooltip, hover card |
https://www.radix-ui.com/primitives/docs/components/dropdown-menu (and sibling component pages) |
| Radix accessibility audit checklist |
https://www.radix-ui.com/primitives/docs/overview/accessibility plus ork:accessibility |
Detailed Documentation
| Resource |
Description |
| scripts/ |
Templates: CVA component, extended button, dialog, dropdown, theme CSS |
| references/ork-delta.md |
Ork floors, scars, and house decisions kept out of upstream docs |
Design System
Design token architecture, spacing, typography, and interactive component states.
| Rule |
File |
Key Pattern |
| Token Architecture |
rules/design-system-tokens.md |
W3C tokens, OKLCH colors, Tailwind @theme |
| Spacing Scale |
rules/design-system-spacing.md |
8px grid, Tailwind space-1 to space-12 |
| Typography Scale |
rules/design-system-typography.md |
Font sizes, weights, line heights |
| Component States |
rules/design-system-states.md |
Hover, focus, active, disabled, loading, animation presets |
Design System Components
Component architecture patterns with atomic design and accessibility.
| Rule |
File |
Key Pattern |
| Component Architecture |
rules/design-system-components.md |
Atomic design, CVA variants, WCAG 2.1 AA, Storybook |
Forms
React Hook Form v7 with Zod validation and React 19 Server Actions.
| Rule |
File |
Key Pattern |
| React Hook Form |
rules/forms-react-hook-form.md |
useForm, field arrays, Controller, wizards, file uploads |
| Zod & Server Actions |
rules/forms-validation-zod.md |
Zod schemas, Server Actions, useActionState, async validation |
Modern CSS & Tooling
Modern CSS patterns, Tailwind v4, and component documentation tooling for 2026.
| Rule |
File |
Key Pattern |
| CSS Cascade Layers |
rules/css-cascade-layers.md |
@layer ordering, specificity-free overrides, third-party isolation |
| Tailwind v4 |
rules/tailwind-v4-patterns.md |
CSS-first @theme, native container queries, @max-* variants |
| Storybook Docs |
rules/storybook-component-docs.md |
CSF3 stories, play() interaction tests, Chromatic visual regression |
UX Foundations
Cognitive-science-grounded UI/UX principles with specific numeric thresholds for production-quality interfaces.
| Rule |
File |
Key Pattern |
| Visual Hierarchy |
rules/visual-hierarchy.md |
Button tiers, de-emphasis, F/Z scan, Von Restorff, proximity, max-width |
| Typography Thresholds |
rules/typography-thresholds.md |
65ch line length, 1.4–1.6 line height, rem units, modular type scale |
| Color System |
rules/color-system.md |
OKLCH 9-shade scales, semantic categories, no true black, brand-tinted neutrals |
| Empty States |
rules/empty-states.md |
Skeleton-first, icon + headline + description + CTA, cause-specific tone |
Related Skills
ork:accessibility - WCAG compliance and React Aria patterns
ork:testing-unit - Component testing patterns
1---2name: ui-components3description: 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.4license: MIT5---6
7# UI Components
8
9Patterns for building accessible UI component libraries with shadcn/ui and Radix Primitives, as a thin wrap over the first-party docs: quick-start recipes, key decisions, anti-patterns, and the house delta. Vendor mechanics (CVA variants, cn() utility, component extension, asChild composition, dialog/menu patterns, data-attribute styling) are upstream's job; see [Upstream coverage (do not restate)](#upstream-coverage-do-not-restate). Each remaining category has individual rule files in `rules/` loaded on-demand.
10
11## Quick Reference
12
13| Category | Rules | Impact | When to Use |
14|----------|-------|--------|-------------|
15| [shadcn/ui](#shadcnui) | 1 | HIGH | v4 styles, preset codes, style detection |
16| [Design System](#design-system) | 4 | HIGH | W3C tokens, OKLCH theming, spacing scales, typography, component states, animation |
17| [Design System Components](#design-system-components) | 1 | HIGH | Atomic design, CVA variants, accessibility, Storybook |
18| [Forms](#forms) | 2 | HIGH | React Hook Form v7, Zod validation, Server Actions |
19| [Modern CSS & Tooling](#modern-css--tooling) | 3 | HIGH | CSS cascade layers, Tailwind v4, Storybook CSF3 |
20| [UX Foundations](#ux-foundations) | 4 | HIGH | Visual hierarchy, typography thresholds, color system, empty states |
21
22**Total: 15 rules across 6 categories.** Radix primitive mechanics and shadcn
23customization tutorials are first-party documented; see
24[Upstream coverage (do not restate)](#upstream-coverage-do-not-restate) and
25[references/ork-delta.md](references/ork-delta.md) for what stays ours.
26
27## Quick Start
28
29```tsx
30// CVA variant system with cn() utility
31import { cva, type VariantProps } from 'class-variance-authority'
32import { cn } from '@/lib/utils'
33
34const buttonVariants = cva(
35 'inline-flex items-center justify-center rounded-md font-medium transition-colors',
36 {
37 variants: {
38 variant: {
39 default: 'bg-primary text-primary-foreground hover:bg-primary/90',
40 destructive: 'bg-destructive text-destructive-foreground',
41 outline: 'border border-input bg-background hover:bg-accent',
42 ghost: 'hover:bg-accent hover:text-accent-foreground',
43 },
44 size: {
45 default: 'h-10 px-4 py-2',
46 sm: 'h-9 px-3',
47 lg: 'h-11 px-8',
48 },
49 },
50 defaultVariants: { variant: 'default', size: 'default' },
51 }
52)
53```
54
55```tsx
56// Radix Dialog with asChild composition
57import { Dialog } from 'radix-ui'
58
59<Dialog.Root>
60 <Dialog.Trigger asChild>
61 <Button>Open</Button>
62 </Dialog.Trigger>
63 <Dialog.Portal>
64 <Dialog.Overlay className="fixed inset-0 bg-black/50" />
65 <Dialog.Content className="data-[state=open]:animate-in">
66 <Dialog.Title>Title</Dialog.Title>
67 <Dialog.Description>Description</Dialog.Description>
68 <Dialog.Close>Close</Dialog.Close>
69 </Dialog.Content>
70 </Dialog.Portal>
71</Dialog.Root>
72```
73
74## shadcn/ui
75
76Beautifully designed, accessible components built on CVA variants, cn() utility, and OKLCH theming.
77
78| Rule | File | Key Pattern |
79|------|------|-------------|
80| v4 Styles | `rules/shadcn-v4-styles.md` | 6 styles (Vega→Luma), preset codes, style detection, class mapping |
81
82Customization, form, and data-table walkthroughs are upstream's job now; see
83[Upstream coverage (do not restate)](#upstream-coverage-do-not-restate). Our
84conventions on top of them live in [references/ork-delta.md](references/ork-delta.md).
85
86### v4 Style System
87
88shadcn CLI v4 ships 6 visual styles. Each rewrites component class names — not just CSS variables.
89
90| Style | Character | Best For |
91|-------|-----------|----------|
92| **Vega** | Balanced radius, clean lines | General purpose (successor to New York) |
93| **Nova** | Compact padding, reduced margins | Dense dashboards, admin panels |
94| **Maia** | Soft, rounded, generous spacing | Consumer-facing, friendly apps |
95| **Lyra** | Sharp, zero radius, monospace pairs | Editorial, developer tools |
96| **Mira** | Ultra-compact, minimal chrome | Spreadsheets, data-heavy interfaces |
97| **Luma** | Extreme rounding (`rounded-4xl`), soft elevation (`shadow-md` + ring), breathable layouts | Polished native-app feel, macOS Tahoe-inspired |
98
99Configure 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.
100
101### shadcn CLI v4 (Apr 2026) — new commands
102
103| Command | Purpose |
104|---------|---------|
105| `npx shadcn@latest apply <style>` | Apply a published style (e.g. `luma`, `nova`, `lyra`) to the current project — re-skins existing components without re-adding them |
106| `npx shadcn@latest info` | Show resolved config: registry, style, tokens, components present, Tailwind version |
107| `npx shadcn@latest skills` | List the `shadcn/skills` registry — Claude Code- and Cursor-ready skill packs that bundle CLI commands with agent guidance |
108| `npx shadcn@latest build` | Build a custom registry (already-documented) — pair with `apply` to ship a private style |
109
110**Detection:** Read `components.json` → `"style"` field (e.g., `"radix-luma"`, `"base-nova"`). Old `"new-york"` and `"default"` styles are superseded by Vega.
111
112## Key Decisions
113
114| Decision | Recommendation |
115|----------|----------------|
116| Color format | OKLCH for perceptually uniform theming |
117| Class merging | Always use cn() for Tailwind conflicts |
118| Extending components | Wrap, don't modify source files |
119| Variants | Use CVA for type-safe multi-axis variants |
120| Styling approach | Data attributes + Tailwind arbitrary variants |
121| Composition | Use `asChild` to avoid wrapper divs |
122| Animation | CSS-only with data-state selectors |
123| Form components | Combine with react-hook-form |
124| Destructive confirmations | AlertDialog, never plain Dialog (see [references/ork-delta.md](references/ork-delta.md)) |
125
126## Anti-Patterns (FORBIDDEN)
127
128- **Modifying shadcn source**: Wrap and extend instead of editing generated files
129- **Skipping cn()**: Direct string concatenation causes Tailwind class conflicts
130- **Inline styles over CVA**: Use CVA for type-safe, reusable variants
131- **Wrapper divs**: Use `asChild` to avoid extra DOM elements
132- **Missing Dialog.Title**: Every dialog must have an accessible title
133- **Positive tabindex**: Using `tabindex > 0` disrupts natural tab order
134- **Color-only states**: Use data attributes + multiple indicators
135- **Manual focus management**: Use Radix built-in focus trapping
136
137## Upstream coverage (do not restate)
138
139These topics were removed from this skill on 2026-07-31 because a first-party
140source owns them. Point sessions at the source; keep only floors, scars, and
141house decisions here (they live in [references/ork-delta.md](references/ork-delta.md)).
142
143| Topic | First-party source |
144|-------|--------------------|
145| shadcn setup, init checklist, adding components | vercel:shadcn (marketplace skill), https://ui.shadcn.com/docs/installation |
146| shadcn customization, CVA variants, cn() utility, component extension | vercel:shadcn (marketplace skill), https://ui.shadcn.com/docs and https://cva.style/docs |
147| OKLCH theming variables, light/dark CSS variable sets | https://ui.shadcn.com/docs/theming |
148| Dark mode toggle with next-themes | https://ui.shadcn.com/docs/dark-mode and https://github.com/pacocoursey/next-themes |
149| Data table with TanStack Table | https://ui.shadcn.com/docs/components/data-table and https://tanstack.com/table |
150| Form field wrappers and validation states | https://ui.shadcn.com/docs/components/form |
151| Radix Dialog and AlertDialog patterns | https://www.radix-ui.com/primitives/docs/components/dialog and .../components/alert-dialog |
152| Radix asChild / Slot composition | https://www.radix-ui.com/primitives/docs/guides/composition |
153| Radix data-attribute styling and focus management | https://www.radix-ui.com/primitives/docs/guides/styling |
154| Dropdown menu, popover, tooltip, hover card | https://www.radix-ui.com/primitives/docs/components/dropdown-menu (and sibling component pages) |
155| Radix accessibility audit checklist | https://www.radix-ui.com/primitives/docs/overview/accessibility plus `ork:accessibility` |
156
157## Detailed Documentation
158
159| Resource | Description |
160|----------|-------------|
161| [scripts/](scripts/) | Templates: CVA component, extended button, dialog, dropdown, theme CSS |
162| [references/ork-delta.md](references/ork-delta.md) | Ork floors, scars, and house decisions kept out of upstream docs |
163
164## Design System
165
166Design token architecture, spacing, typography, and interactive component states.
167
168| Rule | File | Key Pattern |
169|------|------|-------------|
170| Token Architecture | `rules/design-system-tokens.md` | W3C tokens, OKLCH colors, Tailwind @theme |
171| Spacing Scale | `rules/design-system-spacing.md` | 8px grid, Tailwind space-1 to space-12 |
172| Typography Scale | `rules/design-system-typography.md` | Font sizes, weights, line heights |
173| Component States | `rules/design-system-states.md` | Hover, focus, active, disabled, loading, animation presets |
174
175## Design System Components
176
177Component architecture patterns with atomic design and accessibility.
178
179| Rule | File | Key Pattern |
180|------|------|-------------|
181| Component Architecture | `rules/design-system-components.md` | Atomic design, CVA variants, WCAG 2.1 AA, Storybook |
182
183## Forms
184
185React Hook Form v7 with Zod validation and React 19 Server Actions.
186
187| Rule | File | Key Pattern |
188|------|------|-------------|
189| React Hook Form | `rules/forms-react-hook-form.md` | useForm, field arrays, Controller, wizards, file uploads |
190| Zod & Server Actions | `rules/forms-validation-zod.md` | Zod schemas, Server Actions, useActionState, async validation |
191
192## Modern CSS & Tooling
193
194Modern CSS patterns, Tailwind v4, and component documentation tooling for 2026.
195
196| Rule | File | Key Pattern |
197|------|------|-------------|
198| CSS Cascade Layers | `rules/css-cascade-layers.md` | @layer ordering, specificity-free overrides, third-party isolation |
199| Tailwind v4 | `rules/tailwind-v4-patterns.md` | CSS-first @theme, native container queries, @max-* variants |
200| Storybook Docs | `rules/storybook-component-docs.md` | CSF3 stories, play() interaction tests, Chromatic visual regression |
201
202## UX Foundations
203
204Cognitive-science-grounded UI/UX principles with specific numeric thresholds for production-quality interfaces.
205
206| Rule | File | Key Pattern |
207|------|------|-------------|
208| Visual Hierarchy | `rules/visual-hierarchy.md` | Button tiers, de-emphasis, F/Z scan, Von Restorff, proximity, max-width |
209| Typography Thresholds | `rules/typography-thresholds.md` | 65ch line length, 1.4–1.6 line height, rem units, modular type scale |
210| Color System | `rules/color-system.md` | OKLCH 9-shade scales, semantic categories, no true black, brand-tinted neutrals |
211| Empty States | `rules/empty-states.md` | Skeleton-first, icon + headline + description + CTA, cause-specific tone |
212
213## Related Skills
214
215- `ork:accessibility` - WCAG compliance and React Aria patterns
216- `ork:testing-unit` - Component testing patterns