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.json

Usage

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
Toaster properties
PropTypeDefaultDescription
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
timeout
number | undefined
number | undefined
5000The 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 | undefined
number | undefined
3The 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> | undefined
ToastManager<any> | undefined
toastA global manager for toasts to use outside of a React component.
Toast
Toast properties
PropTypeDefaultDescription
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> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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) | undefined
string | ((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
ToastAction properties
PropTypeDefaultDescription
nativeButton
boolean | undefined
boolean | undefined
trueWhether 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> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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 | undefined
boolean | undefined
—Prevents user interaction.
name
string | undefined
string | 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[] | undefined
string | number | readonly string[] | undefined
—The current value when controlled by the application.
className
string | ((state: ToastActionState) => string | undefined) | undefined
string | ((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
ToastClose properties
PropTypeDefaultDescription
nativeButton
boolean | undefined
boolean | undefined
trueWhether 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> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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 | undefined
boolean | undefined
—Prevents user interaction.
name
string | undefined
string | 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[] | undefined
string | number | readonly string[] | undefined
—The current value when controlled by the application.
className
string | ((state: ToastCloseState) => string | undefined) | undefined
string | ((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
ToastContent properties
PropTypeDefaultDescription
ref
React.Ref<HTMLDivElement> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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) | undefined
string | ((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
ToastDescription properties
PropTypeDefaultDescription
ref
React.Ref<HTMLParagraphElement> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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) | undefined
string | ((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
ToastPortal properties
PropTypeDefaultDescription
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> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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) | undefined
string | ((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
ToastProvider properties
PropTypeDefaultDescription
children
React.ReactNode
React.ReactNode
—Content rendered inside this component.
timeout
number | undefined
number | undefined
5000The 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 | undefined
number | undefined
3The 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> | undefined
ToastManager<any> | undefined
—A global manager for toasts to use outside of a React component.
ToastTitle
ToastTitle properties
PropTypeDefaultDescription
ref
React.Ref<HTMLHeadingElement> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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) | undefined
string | ((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
ToastViewport properties
PropTypeDefaultDescription
ref
React.Ref<HTMLDivElement> | undefined
React.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 | undefined
string | undefined
—Unique identifier used to associate labels and descriptions.
children
React.ReactNode
React.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) | undefined
string | ((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.