shadcn/ui Essentials (Repo-Specific)
Use this skill to add or adapt shadcn/ui components in this monorepo without fighting local conventions.
Scope
- Focus on
apps/ui. - Keep instructions lean and stable.
- Use official shadcn docs for evolving details instead of copying full docs into this skill
Source of Truth
Read these files first in the target repo:
apps/ui/components.jsonapps/ui/package.jsonapps/ui/src/lib/styles.tsapps/ui/src/styles/globals.css
Current repo conventions to preserve:
cn()lives in@/lib/styles(not@/lib/utils).- UI components are in
apps/ui/src/components/ui. - Aliases are defined in
apps/ui/components.json. - Existing primitives commonly import from the
radix-uipackage in this repo. - Tailwind is configured for v4-style CSS entry (
components.json.tailwind.css).
Workflow
- Confirm target component(s) and whether this is add vs. refactor.
- Run shadcn CLI from
apps/ui:pnpm dlx shadcn@latest add <component>
- Run the post-install fixup checklist (see below).
- Integrate component usage where requested.
- Validate:
pnpm --filter @repo/ui typecheckpnpm --filter @repo/ui lint
Post-Install Fixup Checklist
After shadcn add, review generated files for these common issues:
cn()import path: The CLI should generate@/lib/styles(aliased incomponents.json). If it generates@/lib/utils, fix the import. This is the most common issue after shadcn upgrades.- Radix imports: This repo uses the unified
radix-uipackage. If generated code imports from@radix-ui/react-*(scoped packages), convert toradix-uiimports unless both coexist inpackage.json. - Tailwind v4 CSS variables: Shadcn v4 components use CSS custom properties (
--radius,--primary, etc.) defined inapps/ui/src/styles/globals.css. Verify new components reference variables that exist in globals.css — add missing ones if needed. "use client"directive: Shadcn components with interactivity include"use client". Keep it — this is a React Server Components project.- Naming conflicts: Check
apps/ui/src/components/ui/for existing files before adding. If a component already exists, diff and merge rather than overwrite.
Common Pitfalls
- Don't use
tailwind.config.js: This project uses Tailwind v4 with CSS-based config (src/styles/globals.css). Theme tokens live inpackages/design-system/src/theme.css. Never create or reference a JS config file. - Don't install duplicate primitives: Before adding a shadcn component that depends on a Radix primitive, check if that primitive is already installed. Run
pnpm --filter @repo/ui list radix-uito check. - Don't override design system tokens: Shadcn components may define their own color/spacing variables. Always prefer existing tokens from
packages/design-system/src/theme.cssover shadcn defaults.
Guardrails
- Do not paste frozen dependency matrices into this skill.
- Do not assume old Tailwind v3 config patterns (
tailwind.config.js,@tailwind baseblocks). - Do not force conversion between
radix-ui,@radix-ui/*, or Base UI unless user requests migration. - Follow existing codebase patterns over generic shadcn examples.
Official References
- Docs home: https://ui.shadcn.com/docs
- Shadcn LLM Docs: https://ui.shadcn.com/llms.txt
- Next.js install: https://ui.shadcn.com/docs/installation/next
- Tailwind v4: https://ui.shadcn.com/docs/tailwind-v4
- CLI: https://ui.shadcn.com/docs/cli
- Components: https://ui.shadcn.com/docs/components