Toast

A customizable and responsive toast notification system.

Installation

npx shadcn@latest add https://scrollxui.dev/registry/toast.json 

Usage

//First, wrap your application with the ToastProvider:
import { ToastProvider } from "@/components/ui/toast";
 
function App() {
  return (
    <ToastProvider>
      <YourApp />
    </ToastProvider>
  );
}
import { useToast } from "@/components/ui/toast";
 
 return function MyComponent() {
  const { toast } = useToast();
  
  const showToast = () => {
    toast({
      title: "Success!",
      description: "Your action was completed successfully.",
      variant: "success",
    });
  }
 }

Examples


Default


Warning


Error


Delete


Info


Success


With Action


Persistent


Promise


Rich Content


Custom Duration


Bulk Actions

API Reference

toast

Triggers a toast notification.

Props

PropertyTypeDefaultDescription
idstringauto
Unique identifier for the toast. Auto-generated if not provided.
titlestring
Main heading text of the toast.
descriptionstring
Optional descriptive message body.
variant"default" | "success" | "destructive" | "warning" | "info" | "loading""default"
Visual style of the toast. Affects colors and icon.
position"top-right" | "top-left" | "bottom-right" | "bottom-left""top-right"
Screen position where the toast appears.
durationnumber5000
Auto-dismiss timeout in milliseconds. Use `Infinity` to disable auto-dismiss.
actionReactNode | { label: string; onClick: () => void }
Optional custom action element or config object with label and callback.
cancel{ label: string; onClick: () => void }
Optional cancel button with label and callback.
onClose() => void
Callback fired when the toast is closed or dismissed.
stackIndexnumber0
Index of the toast in a stack (used internally for stacked animations).
isVisiblebooleantrue
Controls the visibility of the toast.
isStackedbooleanfalse
Indicates if the toast is visually stacked with others.
isHoveredbooleanfalse
Indicates if the stack is hovered (pauses auto-dismiss).
stackDirection"up" | "down""down"
Direction in which stacked toasts collapse/expand.
isExitingbooleanfalse
Indicates if the toast is currently exiting (used for animation timing).
totalCountnumber1
Total number of toasts in the stack (used for '+N' badge).

Built withby Ahdeetai.