DeveloperBreeze

ShadCN Cheatsheet

Initial Setup

# Install shadcn/ui CLI
npx shadcn-ui@latest init

During setup, you'll choose:

  • Framework (Next.js, Vite, etc.)
  • Tailwind CSS config
  • Components directory (default: components)
  • Alias for imports (optional)

Installing Components

npx shadcn-ui@latest add [component]

Example:

npx shadcn-ui@latest add button
npx shadcn-ui@latest add card
npx shadcn-ui@latest add input

Multiple components:

npx shadcn-ui@latest add button card input

Popular Components

ComponentCommand
Buttonnpx shadcn-ui@latest add button
Inputnpx shadcn-ui@latest add input
Dialognpx shadcn-ui@latest add dialog
Cardnpx shadcn-ui@latest add card
Tooltipnpx shadcn-ui@latest add tooltip
AlertDialognpx shadcn-ui@latest add alert-dialog
Dropdown Menunpx shadcn-ui@latest add dropdown-menu
Tabsnpx shadcn-ui@latest add tabs
Avatarnpx shadcn-ui@latest add avatar
Badgenpx shadcn-ui@latest add badge
Accordionnpx shadcn-ui@latest add accordion
Selectnpx shadcn-ui@latest add select
Switchnpx shadcn-ui@latest add switch
Toastnpx shadcn-ui@latest add toast
Skeletonnpx shadcn-ui@latest add skeleton

Theming

Change Theme Colors

Update Tailwind config:

theme: {
  extend: {
    colors: {
      primary: 'hsl(var(--primary))',
      // etc.
    }
  }
}

Modify Default Theme

Edit components/theme.ts or tailwind.config.js


Customization

Change Component Output Directory

npx shadcn-ui@latest init
# Select or type a new directory (e.g. `ui` or `components/ui`)

Customize Tailwind Colors

npx shadcn-ui@latest add theme

Updating Components

npx shadcn-ui@latest add [component] --overwrite

Testing Setup

ShadCN doesn’t include tests by default. Use:

  • @testing-library/react
  • vitest or jest

Example:

npm install --save-dev @testing-library/react @testing-library/jest-dom

Folder Structure (Recommended)

components/

 ui/           # All ShadCN UI components
    button.tsx
    card.tsx
    ...
 shared/       # Your own custom UI components
 layout/       # Layout wrappers

Useful Commands Summary

ActionCommand
Init Projectnpx shadcn-ui@latest init
Add Componentnpx shadcn-ui@latest add [component]
Add Themenpx shadcn-ui@latest add theme
Overwrite Componentnpx shadcn-ui@latest add [component] --overwrite
Add Multiple Componentsnpx shadcn-ui@latest add button card tooltip

Docs & More

Related Posts

More content you might like

Cheatsheet

ملخص شامل لقوانين الإلكترونيات: دليل كامل للرموز والمعادلات الأساسية

  • سليكون: <span class="katex">0.7\;\text{V}</span>
  • جرمانيوم: <span class="katex">0.3\;\text{V}</span>
  • شوتكي: <span class="katex">0.2\text{–}0.3\;\text{V}</span>

العلاقة بين التيار:

Nov 11, 2025
Read More
Cheatsheet

قائمة القوانين الأساسية في الإلكترونيات: دليل شامل وسريع للمهندسين والهواة

  • KVL: مجموع الجهود في مسار = صفر
  • KCL: مجموع التيارات الداخلة = الخارجة
  • Vout = Vin × (R2 ÷ (R1 + R2))
  • Vout = جهد الخرج
  • Vin = جهد الدخل

Nov 11, 2025
Read More
Tutorial

Globalization in React (2025 Trends & Best Practices)

i18n.changeLanguage('ar');
new Intl.DateTimeFormat('fr-FR').format(new Date());
// Output: 04/05/2025 (French format)

May 04, 2025
Read More

Discussion 0

Please sign in to join the discussion.

No comments yet. Be the first to share your thoughts!