NeoTerm UI

useToast

Toast state management hook for triggering notifications.

Import

import { useToast, ToastStack } from "neoterm-ui";

Usage

const { toasts, addToast, dismissToast, dismissAll } = useToast();

addToast({ title: "Saved", status: "success", duration: 3000 });

// Render the stack somewhere in your layout:
<ToastStack toasts={toasts} onDismiss={dismissToast} />

Returns

PropTypeDefaultDescription
toastsToastData[]Active toasts array.
addToast(toast) => stringAdd a toast; returns its id.
dismissToast(id: string) => voidRemove a specific toast.
dismissAll() => voidClear all toasts.