C
Cassa UI

@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

PropTypeDefaultDescription
toast.success(message, options?)functionShow a success toast.
toast.error(message, options?)functionShow an error toast.
toast.warning(message, options?)functionShow a warning toast.
toast.info(message, options?)functionShow an info toast.

Options

PropTypeDefaultDescription
durationnumber4000Auto-dismiss delay in ms. Pass 0 for persistent.
descriptionstringSecondary text shown below the title.