Skip to content

useToast

function useToast(): (toast) => void;

Push toast notifications from anywhere inside a ToastHost.

A function that accepts a toast payload (without id).

(toast): void;
ParameterType
toastOmit<Toast, "id">

void

const toast = useToast();
toast({ message: "Saved!", variant: "success" });
toast({ title: "Error", message: "Network failure", variant: "error", durationMs: 5000 });

A single toast notification.

PropertyTypeDescription
durationMs?numberAuto-dismiss duration in ms. Default 3000. Set 0 to persist.
idstringUnique identifier (auto-generated by useToast).
messagestringMain message body.
title?stringOptional bold title above the message.
variant?ToastVariantColor variant. Default "info".