NeoTerm UI

Toast

Toast notification system with auto-dismiss and stacking.

Import

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

Usage

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

  return (
    <>
      <Button onClick={() => addToast({
        title: "Saved",
        description: "Changes saved successfully.",
        status: "success",
      })}>
        Save
      </Button>
      <ToastStack toasts={toasts} onDismiss={dismissToast} position="bottom-right" />
    </>
  );
}

useToast return

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

ToastStack Props

PropTypeDefaultDescription
toastsToastData[]Toasts to display.
onDismiss(id: string) => voidDismiss callback.
position"top-right" | "top-left" | "bottom-right" | "bottom-left""top-right"Stack position.

ToastData

PropTypeDefaultDescription
idstringUnique id.
titlestringToast headline.
descriptionstringDetail text.
status"success" | "warning" | "error" | "info"Color variant.
durationnumberAuto-dismiss ms.