// With groups
```
---
### Checkbox
**Purpose**: Boolean selection, multi-select
```tsx
import { Checkbox } from '@/components/ui/checkbox';
// Basic checkbox
// With controlled state
// Indeterminate state (select all)
```
---
### Label
**Purpose**: Form field labels (accessibility)
```tsx
import { Label } from '@/components/ui/label';
// Basic label
// With required indicator
// With helper text
Choose a unique username (3-20 characters)
```
**Accessibility**: Always associate labels with inputs using `htmlFor` and `id`.
---
## Feedback Components
### Alert
**Purpose**: Important messages, notifications
```tsx
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
import { AlertCircle, CheckCircle, Info } from 'lucide-react';
// Info alert (default)
Heads up!
This is an informational message.
// Error alert
Error
Something went wrong. Please try again.
// Success alert (custom)
Success!
Your changes have been saved.
// Minimal alert (description only)
Session will expire in 5 minutes.
```
**When to use:**
- ✅ Form-level errors
- ✅ Important warnings
- ✅ Success confirmations (inline)
- ❌ Don't use for transient notifications (use Toast)
---
### Toast (Sonner)
**Purpose**: Transient notifications, feedback
```tsx
import { toast } from 'sonner';
// Success
toast.success('User created successfully');
// Error
toast.error('Failed to delete user');
// Info
toast.info('Processing your request...');
// Warning
toast.warning('This action cannot be undone');
// Loading (with promise)
toast.promise(saveChanges(), {
loading: 'Saving changes...',
success: 'Changes saved!',
error: 'Failed to save changes',
});
// Custom with action
toast('Event has been created', {
description: 'Monday, January 3rd at 6:00pm',
action: {
label: 'Undo',
onClick: () => undoAction(),
},
});
// Dismiss all toasts
toast.dismiss();
```
**When to use:**
- ✅ Action confirmations (saved, deleted)
- ✅ Background task updates
- ✅ Temporary errors
- ❌ Critical errors (use Alert)
- ❌ Form validation errors (use inline errors)
---
### Skeleton
**Purpose**: Loading placeholders
```tsx
import { Skeleton } from '@/components/ui/skeleton';
// Basic skeleton
// Card skeleton
// Avatar skeleton
// Table skeleton
;
}
```
---
## Overlay Components
### Dialog
**Purpose**: Modal windows, confirmations, forms
```tsx
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
DialogTrigger,
DialogClose,
} from '@/components/ui/dialog';
// Basic dialog
;
// Controlled dialog
const [isOpen, setIsOpen] = useState(false);
;
```
**Accessibility:**
- Escape key closes dialog
- Focus trapped inside dialog
- Returns focus to trigger on close
---
### Dropdown Menu
**Purpose**: Action menus, user menus, context menus
```tsx
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuGroup,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuCheckboxItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem
} from '@/components/ui/dropdown-menu';
// Basic dropdown
Edit
Duplicate
Delete
// User menu
{user.initials}My AccountProfileSettingsLogout
// With checkboxes
Show Columns
Name
Email
```
---
### Popover
**Purpose**: Contextual information, mini-forms
```tsx
import {
Popover,
PopoverContent,
PopoverTrigger
} from '@/components/ui/popover';
// Basic popover
Popover Title
Popover content goes here
// With form
```
---
### Sheet
**Purpose**: Side panels, mobile navigation
```tsx
import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
SheetDescription,
SheetTrigger,
SheetFooter,
SheetClose
} from '@/components/ui/sheet';
// Basic sheet
Sheet Title
Sheet description goes here
{/* Content */}
// Side variants
...... {/* Default */}
......
// Mobile navigation pattern
```
---
## Data Display Components
### Table
**Purpose**: Display tabular data
```tsx
import {
Table,
TableHeader,
TableBody,
TableFooter,
TableHead,
TableRow,
TableCell,
TableCaption,
} from '@/components/ui/table';
A list of your recent invoicesInvoiceStatusMethodAmount
{invoices.map((invoice) => (
{invoice.id}{invoice.status}{invoice.method}{invoice.amount}
))}
Total$2,500.00