shadcn-setup
Initialize Shadcn UI in an EXISTING Next.js or React (Vite) project.
Installation
Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.
Voir la source ↗GuidesInstructions
Shadcn Setup
Use this skill to add Shadcn UI to a project that already exists but doesn't have it configured.
Documentation
Workflow
1. Environment & Prerequisites Detection
Before initializing, ensure the environment is ready:
A. Framework
-
Next.js: check for
next.config.jsornext.config.ts. -
Vite: check for
vite.config.tsorvite.config.js.
B. Tailwind CSS (CRITICAL)
Shadcn requires Tailwind CSS. Verify it is installed and configured:
- Check for
tailwind.config.js/tailwind.config.ts(v3). - OR check for specific Tailwind v4 CSS imports in
globals.css/index.css. -
If missing: Install Tailwind CSS first (follow official Tailwind guides for the specific framework). DO NOT proceed with
shadcn initwithout Tailwind.
C. Path Aliases (tsconfig.json)
Shadcn relies on path aliases (e.g., @/lib/utils).
- Read
tsconfig.json(orjsconfig.json). - Ensure
"paths": { "@/*": ["./src/*"] }(or similar) is configured. -
If missing: Add the alias configuration to
compilerOptions.
2. Initialization
Run the init command using pnpm:
pnpm dlx shadcn@latest init
3. Configuration
Follow these defaults unless specified otherwise:
- Style: New York (Default) or Default.
- Base Color: Slate.
- CSS Variables: YES (Critical for dynamic theming).
-
Aliasing: Accept defaults (usually
@/components,@/lib/utils) or matchtsconfig.json.
4. Cleanup & Boilerplate Removal
For Next.js (app/)
-
Clean
page.tsx: Replace default Next.js hero content with a simple shadcn Button to verify setup. -
Clean
globals.css: Remove all default styling (root variables for foreground/background-rgb) EXCEPT:- Tailwind directives (
@tailwind base;...) - Shadcn layer definitions (
@layer base { ... })
- Tailwind directives (
For Vite (src/)
-
Clean
App.tsx: Removelogos,countstate, and default boilerplates. Replace with a simple shadcn content. -
Clean
index.css: Ensure it contains Tailwind directives and Shadcn base layers. Remove legacy:rootstyles if they conflict.
5. Verification
- Check
components.jsonexists. - Check
lib/utils.ts(or configured alias) exists and exportscn.
References
Exemples
Consultez les exemples du dépôt source.
Voir la source ↗Historique source
- Date d’indexation
- 2026-03-11
- Mise à jour de l’index
- 2026-03-11
- Branch
- main
Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!