# Component Usage Guide **Last Updated**: 2025-01-27 **Purpose**: Guide for when and how to use design system components ## Table of Contents 1. [Button](#button) 2. [Card](#card) 3. [Input](#input) 4. [Select](#select) 5. [Dialog](#dialog) 6. [Alert](#alert) 7. [Badge](#badge) 8. [Best Practices](#best-practices) --- ## Button **Location**: `@/components/ui/button` **Import**: `import { Button } from '@/components/ui/button'` ### When to Use ✅ **DO use Button component for:** - All interactive buttons (primary actions, secondary actions, navigation) - Icon buttons - Link-style buttons - Destructive actions (delete, remove) ❌ **DON'T use:** - Native ` // Secondary action // Icon button // Destructive action // Link-style (use ghost with underline) ``` ### Common Patterns **Button Groups:** ```tsx
``` **Icon with Text:** ```tsx ``` --- ## Card **Location**: `@/components/ui/card` **Import**: `import { Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter } from '@/components/ui/card'` ### When to Use ✅ **DO use Card component for:** - Content containers - Dashboard widgets - Feature cards - Data display sections ❌ **DON'T use:** - Custom card implementations - Legacy Card component from `@/components/base/Card` - Invalid `variant` prop (Card doesn't support variants) ### Structure ```tsx Title Optional description {/* Main content */} {/* Footer actions */} ``` ### Examples ```tsx // Simple card Track Statistics

Total plays: 1,234

// Card with footer actions Settings Manage your preferences {/* Settings form */} ``` ### Styling - Card uses className-based styling (no variants) - Use `className` prop for custom styling - Default styles: rounded-2xl, border, background, shadow, hover effects --- ## Input **Location**: `@/components/ui/input` **Import**: `import { Input } from '@/components/ui/input'` ### When to Use ✅ **DO use Input component for:** - Text inputs - Number inputs - Email inputs - Password inputs - Search inputs ❌ **DON'T use:** - Native `` elements (for consistency) - Custom input implementations (unless specialized like AuthInput, ChatInput) ### Examples ```tsx // Basic input setTitle(e.target.value)} /> // With label
setTitle(e.target.value)} />
// Disabled state ``` ### Styling - Input uses consistent styling: rounded-lg, border, background, focus states - Focus state: border-kodo-cyan - Disabled state: opacity-50, cursor-not-allowed --- ## Select **Location**: `@/components/ui/select` **Import**: `import { Select, SelectTrigger, SelectValue, SelectContent, SelectItem } from '@/components/ui/select'` ### When to Use ✅ **DO use Select component for:** - Dropdown selections - Filter options - Sort options - Choice selections ❌ **DON'T use:** - Native ` Option 1 Option 2 Option 3 ``` --- ## Dialog **Location**: `@/components/ui/dialog` **Import**: `import { Dialog } from '@/components/ui/dialog'` ### When to Use ✅ **DO use Dialog component for:** - Confirmation dialogs - Alert dialogs - Information dialogs - Modal forms ### Variants | Variant | Use Case | |---------|----------| | `default` | Standard dialog | | `alert` | Error/warning messages (red icon) | | `confirm` | Confirmation dialogs (cyan icon) | | `info` | Information dialogs (cyan icon) | ### Examples ```tsx // Confirmation dialog setIsOpen(false)} title="Delete Track" variant="alert" onConfirm={handleDelete} confirmLabel="Delete" cancelLabel="Cancel" >

Are you sure you want to delete this track? This action cannot be undone.

``` --- ## Alert **Location**: `@/components/ui/alert` **Import**: `import { Alert, AlertDescription } from '@/components/ui/alert'` ### When to Use ✅ **DO use Alert component for:** - Success messages - Warning messages - Error messages (non-critical) - Information messages ### Examples ```tsx // Success alert Track uploaded successfully! // Error alert Failed to upload track. Please try again. ``` --- ## Badge **Location**: `@/components/ui/badge` **Import**: `import { Badge } from '@/components/ui/badge'` ### When to Use ✅ **DO use Badge component for:** - Status indicators - Tags - Counts - Labels ### Examples ```tsx // Status badge Active Inactive // Count badge 42 ``` --- ## Best Practices ### 1. Always Use Design System Components - ✅ Use `Button` instead of `