bearnie

Toast

Temporary notification messages.

Installation

npx bearnie add toast
npx bearnie add toast

Usage

import { Toaster } from "@/components/bearnie/toast"
toast("Event has been created.")

Examples

With title and description

Success

Error

Warning

Info

Promise

Shows a loading toast that turns into a success or error toast when the promise settles.

With action

Anatomy

  • Toaster - The container that renders toasts (add once to layout)

Props

Toaster

Prop Type Default Description
position top-left | top-center | top-right | bottom-left | bottom-center | bottom-right bottom-right Toast position
max number 5 Maximum toasts shown at once; the oldest is dismissed when exceeded
class string - Additional CSS classes

toast() function

Option Type Default Description
title string - Toast heading
description string - Toast message
type default | success | destructive | warning | info default Toast variant
duration number 4000 Auto-dismiss time (ms). Hovering a toast pauses the timer
action object - Action button config

Helpers: toast.success(), toast.destructive(), toast.warning(), toast.info(), toast.promise(promise, { loading, success, error }), and toast.dismiss(el). The success and error messages accept a string, an options object, or a function receiving the resolved value / rejection reason.