A composable hook and utility for displaying toast notifications, wrapping the Sonner toast library with a custom `showToast` component and normalized variant system. ## Key Components | Export | Type | Description | |--------|------|-------------| | `ToastOptions` | Interface | Configuration options for toast notifications | | `toast` | Function | Displays a toast notification; accepts a string or `ToastOptions` | | `useToast` | Function | Composable returning `toast`, `dismiss`, and `promise` helpers | | `normalizeVariant` | Internal | Maps `'destructive'` → `'error'` for internal variant compatibility | ### `ToastOptions` Fields | Field | Type | Description | |-------|------|-------------| | `title` | `string` | Toast heading text | | `description` | `string` | Optional body text | | `variant` | `string` | Visual style: `default`, `success`, `destructive`, `info`, `warning`, `error` | | `duration` | `number` | Display duration in milliseconds | | `dismissible` | `boolean` | Whether the user can manually dismiss the toast | ## Usage Example ```typescript import { useToast, toast } from '@/hooks/use-toast' // Direct usage toast('Operation completed successfully') toast({ title: 'Error', description: 'Something went wrong.', variant: 'destructive', duration: 5000, }) // Via composable const { toast, dismiss, promise } = useToast() toast({ title: 'Saved', variant: 'success' }) // Promise-based toast promise(fetchData(), { loading: 'Loading...', success: 'Data loaded!', error: 'Failed to load.', }) ``` > **Note:** The `'destructive'` variant is automatically normalized to `'error'` internally to align with the underlying `ToastVariant` type used by the `toaster` component.