Theme
Customize appearance
Components
Toast
Display transient notifications with the Base UI toast manager.
View component source ↗Preview
A minimal example to get started.
Installation
Install this component and its dependencies in a project initialized with shadcn.
pnpm dlx shadcn@latest add https://ui.hyunjoon.net/r/toast.jsonUsage
This is the basic example. Use the Code tab above for the selected example. Adjust import aliases to match your project.
import { Button } from "@/components/ui/button";
import { Toaster, toast } from "@/components/ui/toast";
export default function Example() {
return (
<Toaster>
<Button
onClick={() =>
toast.add({
title: "Saved",
description: "Your preferences were updated.",
type: "success",
})
}
>
Show toast
</Button>
</Toaster>
);
}
API reference
Derived from the installed component types. Native DOM props are also supported where applicable. A dash means no explicit default is documented. Some props depend on the selected mode.
Toaster
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
timeout | number | undefinednumber | undefined | 5000 | The default amount of time (in ms) before a toast is auto dismissed. A value of `0` will prevent the toast from being dismissed automatically. |
limit | number | undefinednumber | undefined | 3 | The maximum number of toasts that can be displayed at once. When the limit is reached, the oldest toast will be removed to make room for the new one. |
toastManager | ToastManager<any> | undefinedToastManager<any> | undefined | toast | A global manager for toasts to use outside of a React component. |
Toast
| Prop | Type | Default | Description |
|---|---|---|---|
toastRequired | ToastRootToastObject<any>ToastRootToastObject<any> | — | The toast to render. |
swipeDirection | "left" | "right" | "up" | "down" | ("left" | "right" | "up" | "down")[] | undefined"left" | "right" | "up" | "down" | ("left" | "right" | "up" | "down")[] | undefined | ['down', 'right'] | Direction(s) in which the toast can be swiped to dismiss. |
ref | React.Ref<HTMLDivElement> | undefinedReact.Ref<HTMLDivElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
className | string | ((state: ToastRootState) => string | undefined) | undefinedstring | ((state: ToastRootState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastRootState> | undefined | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastRootState) => React.CSSProperties | undefined) | undef…React.CSSProperties | ((state: ToastRootState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
ToastAction
| Prop | Type | Default | Description |
|---|---|---|---|
nativeButton | boolean | undefinedboolean | undefined | true | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
ref | React.Ref<HTMLButtonElement> | undefinedReact.Ref<HTMLButtonElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLButtonElement, Element>>) => void) | undefined((event: BaseUIEvent<React.ChangeEvent<HTMLButtonElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLButtonElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLButtonElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLButtonElement, MouseEvent>>) => void) | undefine…((event: BaseUIEvent<React.MouseEvent<HTMLButtonElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
name | string | undefinedstring | undefined | — | Field name used in form data. |
type | "button" | "submit" | "reset" | undefined"button" | "submit" | "reset" | undefined | — | The native input or button behavior. |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
className | string | ((state: ToastActionState) => string | undefined) | undefinedstring | ((state: ToastActionState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastActionState> | undefined | <Button variant="outline" size="sm" /> | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastActionState) => React.CSSProperties | undefined) | und…React.CSSProperties | ((state: ToastActionState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
ToastClose
| Prop | Type | Default | Description |
|---|---|---|---|
nativeButton | boolean | undefinedboolean | undefined | true | Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). |
ref | React.Ref<HTMLButtonElement> | undefinedReact.Ref<HTMLButtonElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLButtonElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLButtonElement, Element>>) => void) | undefined((event: BaseUIEvent<React.ChangeEvent<HTMLButtonElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLButtonElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLButtonElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLButtonElement, MouseEvent>>) => void) | undefine…((event: BaseUIEvent<React.MouseEvent<HTMLButtonElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
disabled | boolean | undefinedboolean | undefined | — | Prevents user interaction. |
name | string | undefinedstring | undefined | — | Field name used in form data. |
type | "button" | "submit" | "reset" | undefined"button" | "submit" | "reset" | undefined | — | The native input or button behavior. |
value | string | number | readonly string[] | undefinedstring | number | readonly string[] | undefined | — | The current value when controlled by the application. |
className | string | ((state: ToastCloseState) => string | undefined) | undefinedstring | ((state: ToastCloseState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastCloseState> | undefined | <Button variant="ghost" size="icon-sm" /> | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastCloseState) => React.CSSProperties | undefined) | unde…React.CSSProperties | ((state: ToastCloseState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
ToastContent
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLDivElement> | undefinedReact.Ref<HTMLDivElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
className | string | ((state: ToastContentState) => string | undefined) | undefinedstring | ((state: ToastContentState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastContentState> | undefined | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastContentState) => React.CSSProperties | undefined) | un…React.CSSProperties | ((state: ToastContentState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
ToastDescription
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLParagraphElement> | undefinedReact.Ref<HTMLParagraphElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLParagraphElement, Element>>) => void) | undefine…((event: BaseUIEvent<React.FocusEvent<HTMLParagraphElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLParagraphElement, Element>>) => void) | undefine…((event: BaseUIEvent<React.FocusEvent<HTMLParagraphElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLParagraphElement, Element>>) => void) | undefin…((event: BaseUIEvent<React.ChangeEvent<HTMLParagraphElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLParagraphElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLParagraphElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLParagraphElement, MouseEvent>>) => void) | undef…((event: BaseUIEvent<React.MouseEvent<HTMLParagraphElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
className | string | ((state: ToastDescriptionState) => string | undefined) | undefinedstring | ((state: ToastDescriptionState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastDescriptionState> | undefined | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastDescriptionState) => React.CSSProperties | undefined) …React.CSSProperties | ((state: ToastDescriptionState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
ToastPortal
| Prop | Type | Default | Description |
|---|---|---|---|
container | HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null | undef…HTMLElement | ShadowRoot | React.RefObject<HTMLElement | ShadowRoot | null> | null | undefined | — | A parent element to render the portal element into. |
ref | React.Ref<HTMLDivElement> | undefinedReact.Ref<HTMLDivElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
className | string | ((state: ToastPortalState) => string | undefined) | undefinedstring | ((state: ToastPortalState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastPortalState> | undefined | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastPortalState) => React.CSSProperties | undefined) | und…React.CSSProperties | ((state: ToastPortalState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
ToastProvider
| Prop | Type | Default | Description |
|---|---|---|---|
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
timeout | number | undefinednumber | undefined | 5000 | The default amount of time (in ms) before a toast is auto dismissed. A value of `0` will prevent the toast from being dismissed automatically. |
limit | number | undefinednumber | undefined | 3 | The maximum number of toasts that can be displayed at once. When the limit is reached, the oldest toast will be removed to make room for the new one. |
toastManager | ToastManager<any> | undefinedToastManager<any> | undefined | — | A global manager for toasts to use outside of a React component. |
ToastTitle
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLHeadingElement> | undefinedReact.Ref<HTMLHeadingElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLHeadingElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLHeadingElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLHeadingElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLHeadingElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLHeadingElement, Element>>) => void) | undefined((event: BaseUIEvent<React.ChangeEvent<HTMLHeadingElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLHeadingElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLHeadingElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLHeadingElement, MouseEvent>>) => void) | undefin…((event: BaseUIEvent<React.MouseEvent<HTMLHeadingElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
className | string | ((state: ToastTitleState) => string | undefined) | undefinedstring | ((state: ToastTitleState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastTitleState> | undefined | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastTitleState) => React.CSSProperties | undefined) | unde…React.CSSProperties | ((state: ToastTitleState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
ToastViewport
| Prop | Type | Default | Description |
|---|---|---|---|
ref | React.Ref<HTMLDivElement> | undefinedReact.Ref<HTMLDivElement> | undefined | — | Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). |
id | string | undefinedstring | undefined | — | Unique identifier used to associate labels and descriptions. |
children | React.ReactNodeReact.ReactNode | — | Content rendered inside this component. |
onFocus | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control receives focus. |
onBlur | ((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.FocusEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the control loses focus. |
onChange | ((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined((event: BaseUIEvent<React.ChangeEvent<HTMLDivElement, Element>>) => void) | undefined | — | Called when the underlying form control changes; inspect the event for its value. |
onKeyDown | ((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined((event: BaseUIEvent<React.KeyboardEvent<HTMLDivElement>>) => void) | undefined | — | Called when a key is pressed while this element is focused. |
onClick | ((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined((event: BaseUIEvent<React.MouseEvent<HTMLDivElement, MouseEvent>>) => void) | undefined | — | Called when the element is activated. |
className | string | ((state: ToastViewportState) => string | undefined) | undefinedstring | ((state: ToastViewportState) => string | undefined) | undefined | — | CSS class applied to the element, or a function that returns a class based on the component's state. |
render | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn…React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ToastViewportState> | undefined | — | Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a `ReactElement` or a function that returns the element to render. |
style | React.CSSProperties | ((state: ToastViewportState) => React.CSSProperties | undefined) | u…React.CSSProperties | ((state: ToastViewportState) => React.CSSProperties | undefined) | undefined | — | Style applied to the element, or a function that returns a style object based on the component's state. |
Usage notes
Mount Toaster and call toast.add to create a notification. Keep important information available elsewhere after the toast disappears.