UI Components
Toast
Global notification system with auto-dismiss, four variants, six positions, and useToast hook
Quick Preview
Installation
// Copy the Toast component fromsrc/components/ui/Toast.tsx
Usage
// 1. Wrap your app (or layout) with ToastProviderimport { ToastProvider } from '@/components/ui/Toast'export default function Layout({ children }) {return (<ToastProvider position="top-right">{children}</ToastProvider>)}// 2. Use the hook anywhere inside the provider'use client'import { useToast } from '@/components/ui/Toast'export default function SaveButton() {const { addToast } = useToast()async function handleSave() {await save()addToast('Changes saved!', { variant: 'success', duration: 3000 })}return <button onClick={handleSave}>Save</button>}
Examples
Positions
Set position on ToastProvider to control where toasts appear. Options: top-right, top-left, top-center, bottom-right, bottom-left, bottom-center.
Custom Duration
Default duration is 4000 ms. Pass a custom duration (ms) in options.
Prompt Preview
Copy a prompt that recreates this UI
Paste this into your AI coding assistant to generate code that closely matches the reference, including color, size, shape, typography, spacing, and polish.
Copy-ready AI prompt
Starts from the current visual reference and project constraints.
Tweak only product-specific copy or data after the first generation pass.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
message* | string | - | Notification message text |
variant | "success" | "error" | "warning" | "info" | "info" | Visual variant |
duration | number | 4000 | Auto-dismiss delay in milliseconds |
position | ToastPosition | "top-right" | Stack position on screen (ToastProvider prop) |
Features
- โContext + useToast hook API
- โToastProvider wraps app (or section)
- โFour variants: success, error, warning, info
- โSix stack positions
- โAuto-dismiss with configurable duration
- โManual dismiss button
- โPortal rendering
- โrole="alert" + aria-live
- โClient Component