DeveloperBreeze

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

Continue Reading

Handpicked posts just for you — based on your current read.

Best Tools for Generating Backgrounds Patterns for Your Website

  • Website: Subtle Patterns
  • Features:
  • A massive collection of subtle and repeatable background patterns.
  • Free to use and download.
  • Patterns are perfect for minimalistic and elegant design aesthetics.
  • Best For: Web designers looking for ready-to-use, subtle background patterns to enhance user experience without overwhelming the design.
  • Website: Coolors
  • Features:
  • Known for its excellent color palette generator, Coolors also provides the ability to generate patterns.
  • Choose colors, add gradients, or even create geometric patterns.
  • Perfect for creating both color schemes and patterns in one place.
  • Best For: Designers who need both color palette inspiration and pattern creation in a single tool.

Oct 21, 2024 Cheatsheet

Discussion 0

Please sign in to join the discussion.

No comments yet. Start the discussion!