@tank/shadcn-mastery
1.0.0Description
Build, customize, and scale design systems with shadcn/ui. Covers CLI and configuration, CSS variable theming and dark mode, component customization with cva variants, data tables with TanStack Table, forms with react-hook-form and zod, charts, the registry system, Radix accessibility primitives, component composition patterns, monorepo setup, and Tailwind CSS v4 integration..
Download
Verified
tank install @tank/shadcn-masteryShadcn Mastery
Core Philosophy
- Open code, not a dependency — shadcn/ui copies component source into the project. Edit files directly instead of wrapping or overriding an npm package. This is the component library you own.
- Semantic tokens drive consistency — Theme with CSS variables (
--primary,--background) rather than raw color values. Every component reads from the same token set, so a single variable change propagates everywhere. - Composition over configuration — Build complex UI by composing small Radix primitives (Dialog + Form, Command + Popover). Avoid prop-drilling feature flags into monolithic components.
- Use the CLI, not copy-paste —
npx shadcn@latest addresolves dependencies, respectscomponents.jsonaliases, and handles monorepo paths. Manual copy-paste breaks this chain. - Radix handles accessibility — Radix primitives ship with ARIA roles, keyboard navigation, and focus management. Customize visuals freely but preserve the primitive structure to keep accessibility intact.
Quick-Start: Common Problems
"How do I set up shadcn/ui?"
- Run
npx shadcn@latest init— select framework, base color, CSS variables - Inspect the generated
components.json— verify aliases matchtsconfig.jsonpaths - Add components:
npx shadcn@latest add button dialog input - Components land in
components/ui/— edit them directly -> Seereferences/cli-and-config.md
"My theme colors look wrong"
- Check
globals.css— tokens must be defined under:rootand.dark - Verify background/foreground pairs:
--primarypairs with--primary-foreground - Confirm
tailwind.cssVariablesistrueincomponents.json - Use
shadcn/createto preview and generate theme presets -> Seereferences/theming-dark-mode.md
"I need a data table with sorting and filtering"
- Add
Tablecomponent:npx shadcn@latest add table - Install TanStack Table:
npm i @tanstack/react-table - Define column definitions in a separate
columns.tsxfile - Wire
useReactTablewith sorting/filtering/pagination state -> Seereferences/data-tables.md
"How do I build a validated form?"
- Add
Field+Input+Labelcomponents - Install
react-hook-form+@hookform/resolvers+zod - Define Zod schema, pass to
useFormviazodResolver - Use
Controller+Fieldfor each form control -> Seereferences/forms-validation.md
"I want to add a custom variant to Button"
- Open
components/ui/button.tsx - Add the variant to the
cvacall inbuttonVariants - Update the
ButtonPropstype to include the new variant -> Seereferences/component-customization.md
Decision Trees
Component Selection
| Need | Component |
|---|---|
| Modal with blocking action | AlertDialog (prevents outside dismiss) |
| Modal with form/content | Dialog (standard dismissible) |
| Side panel | Sheet (slides from edge) |
| Mobile-friendly bottom panel | Drawer (swipe-to-dismiss) |
| Search/command launcher | Command (cmdk-powered) |
| Searchable dropdown | Combobox (Command + Popover) |
| Simple dropdown | Select (native-like) |
| Menu with actions | DropdownMenu (right-click or button trigger) |
Overlay Stacking
| Signal | Approach |
|---|---|
| Dialog inside Dialog | Nest Dialog components — Radix manages stacking |
| Form inside Dialog | Compose Dialog + form + Field components |
| Confirmation after action | Use AlertDialog triggered from parent Dialog |
| Sheet with sub-navigation | Use Tabs inside Sheet |
Reference Index
| File | Contents |
|---|---|
references/cli-and-config.md | CLI commands (init, add, build, migrate), components.json schema, path aliases, Tailwind v3/v4 config |
references/theming-dark-mode.md | CSS variable tokens, semantic pairs, dark mode setup, radius scale, custom tokens, base colors |
references/component-customization.md | cva variant patterns, extending components, compound components, cn() utility, adding new primitives |
references/data-tables.md | TanStack Table integration, column definitions, sorting, filtering, pagination, row selection, reusable components |
references/forms-validation.md | react-hook-form + zod + Field component, validation modes, error display, field types, array fields |
references/composition-patterns.md | Dialog + Form, Command palette, Combobox, Sheet vs Dialog, sidebar patterns, toast/sonner |
references/registry-system.md | Registry schema, building custom registries, namespaces, authentication, distribution, MCP server |
references/accessibility-radix.md | Radix primitives, ARIA patterns, keyboard navigation, focus management, screen reader support |