Tessera UI

Toast

Transient floating notifications for short feedback messages, with optional actions and auto-dismiss.

Preview
Loading...

Usage

import { Toast, ToastProvider, Toaster, useToast } from "@tessinaui/ui/toast";

Setup

Wrap your app (or layout) with ToastProvider and place Toaster where you want notifications to appear.

export default function RootLayout({ children }) {
  return (
    <ToastProvider>
      {children}
      <Toaster position="bottom-right" />
    </ToastProvider>
  );
}

Firing a toast

function MyComponent() {
  const { toast } = useToast();

  return (
    <button onClick={() =>
      toast({
        title: "Changes saved",
        description: "Your profile has been updated successfully.",
        intent: "success",
        action: { label: "Undo", onClick: handleUndo },
      })
    }>
      Save
    </button>
  );
}

Showcase

Preview
Loading...

API

Toast

PropTypeDefaultDescription
titleReactNodeBold heading line
descriptionReactNodeSupporting body text
intent"none" | "error" | "warning" | "success" | "info""none"Semantic color and default icon
size"sm" | "md""md"Compact or standard size
iconReactNodeOverrides the default intent icon
showIconbooleantrueShow/hide the leading icon
actionToastActionInline CTA button
onClose() => voidRenders a dismiss (×) button
dir"ltr" | "rtl""ltr"Text direction
classNamestringExtra class names

ToastAction

PropTypeDefaultDescription
labelstringButton label
onClick() => voidClick handler
variantButtonVariant"primary"Button style override

Toaster

PropTypeDefaultDescription
positionToastPosition"bottom-right"Screen corner for the stack
maxVisiblenumber5Max simultaneously shown
defaultDurationnumber5000Auto-dismiss ms (0 = persistent)
defaultSize"sm" | "md""md"Fallback size
defaultDir"ltr" | "rtl""ltr"Fallback direction

useToast

const { toast, dismiss, dismissAll, toasts } = useToast();
ReturnTypeDescription
toast(data: ToastData) => stringAdds a toast; returns its id
dismiss(id: string) => voidRemoves a toast by id
dismissAll() => voidClears all toasts
toastsToastData[]Current toast stack

ToastData

PropTypeDefaultDescription
titleReactNodeHeading (required)
descriptionReactNodeSupporting text
intentToastIntent"none"Semantic color
sizeToastSizeToaster defaultOverride size
dir"ltr" | "rtl"Toaster defaultOverride direction
actionToastActionInline CTA
durationnumber5000ms before auto-dismiss; 0 = persistent
iconReactNodeCustom leading icon
showIconbooleantrueShow/hide icon

Position values

ValueDescription
"top-left"Top-left corner
"top-center"Top-center
"top-right"Top-right corner
"bottom-left"Bottom-left corner
"bottom-center"Bottom-center
"bottom-right"Bottom-right corner (default)

On this page