Sourceful Energy

Toast

A succinct message that is displayed temporarily using Sonner.

Installation

// Add Toaster to your layout
import { Toaster } from "@sourceful-energy/ui"

// In your layout.tsx
<Toaster />

// Use toast function in components
import { toast } from "sonner"

Usage

Examples

Success

Error

Warning

Info

With Description

With Action

Promise Toast

Custom Duration

Dismiss Toast

Props (Toaster)

PropTypeDefaultDescription
position"top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right""bottom-right"The position of the toasts.
expandbooleanfalseWhether toasts should expand to fill available space.
richColorsbooleanfalseUse rich colors for success, error, etc.
closeButtonbooleanfalseShow a close button on each toast.
durationnumber4000Default duration in milliseconds before toasts dismiss.

Accessibility

  • Uses ARIA live regions for screen reader announcements
  • Toasts can be dismissed with keyboard
  • Action buttons are keyboard accessible
  • Respects prefers-reduced-motion for animations