useToast
function useToast(): (toast) => void;Push toast notifications from anywhere inside a ToastHost.
Returns
Section titled “Returns”A function that accepts a toast payload (without id).
(toast): void;Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
toast | Omit<Toast, "id"> |
Returns
Section titled “Returns”void
Example
Section titled “Example”const toast = useToast();
toast({ message: "Saved!", variant: "success" });toast({ title: "Error", message: "Network failure", variant: "error", durationMs: 5000 });A single toast notification.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
durationMs? | number | Auto-dismiss duration in ms. Default 3000. Set 0 to persist. |
id | string | Unique identifier (auto-generated by useToast). |
message | string | Main message body. |
title? | string | Optional bold title above the message. |
variant? | ToastVariant | Color variant. Default "info". |