@cassa/notifications
Toast notification system. Four variants, auto-dismiss with configurable duration, and persistent mode for long-running operations.
Setup
Wrap your app with ToastProvider once at the root:
// app/layout.tsx
import { ToastProvider } from '@cassa/notifications'
export default function RootLayout({ children }) {
return (
<html>
<body>
<ToastProvider>{children}</ToastProvider>
</body>
</html>
)
}Usage
'use client'
import { useToast } from '@cassa/notifications'
export const SaveButton = () => {
const { toast } = useToast()
const save = async () => {
try {
await api.save()
toast.success('Changes saved.')
} catch {
toast.error('Failed to save. Try again.')
}
}
return <button onClick={save}>Save</button>
}All variants
toast methods
| Prop | Type | Default | Description |
|---|---|---|---|
| toast.success(message, options?) | function | — | Show a success toast. |
| toast.error(message, options?) | function | — | Show an error toast. |
| toast.warning(message, options?) | function | — | Show a warning toast. |
| toast.info(message, options?) | function | — | Show an info toast. |
Options
| Prop | Type | Default | Description |
|---|---|---|---|
| duration | number | 4000 | Auto-dismiss delay in ms. Pass 0 for persistent. |
| description | string | — | Secondary text shown below the title. |