- components
- ›
- toast
- ›
- react
Toast
Display brief messages to users.
Usage
This component acts as a Singleton - meaning you only implement a single instance (typically at the root scope of your app) and then reused it over and over. To do this, implement the <Toast.Group>
at the root scope of your app, and use a shared createToaster()
instance to trigger messages to that group from anywhere in your application.
Type
Types can be specified in one of two ways:
- Via a trigger method:
toaster.{info|success|warning|error}()
- Via the object key:
type: {info|success|warning|error}
Action
Include an optional action button.
Closable
By passing closable: false
you can disable the close button.
Placement
Meta
Use the meta
key to provide arbitrary data. Then use this to modify your Toast template.
Promise
Use promises for asynchronous triggers.
API Reference
Root
Property | Default | Type |
---|---|---|
toast | - | Omit<Options<any>, "id" | "parent"> |
element | - | ((attributes: HTMLAttributes<"div">) => Element) | undefinedRender the element yourself |
RootContext
Property | Default | Type |
---|---|---|
children | - | (toast: ToastApi<PropTypes, any>) => ReactNode |
Group
Property | Default | Type |
---|---|---|
toaster | - | ToastStore<any> |
children | - | ((toast: ToastProps<any>) => Element | null) | undefined |
element | - | ((attributes: HTMLAttributes<"div">) => Element) | undefinedRender the element yourself |
Message
Property | Default | Type |
---|---|---|
element | - | ((attributes: HTMLAttributes<"div">) => Element) | undefinedRender the element yourself |
Title
Property | Default | Type |
---|---|---|
element | - | ((attributes: HTMLAttributes<"div">) => Element) | undefinedRender the element yourself |
Description
Property | Default | Type |
---|---|---|
element | - | ((attributes: HTMLAttributes<"div">) => Element) | undefinedRender the element yourself |
ActionTrigger
Property | Default | Type |
---|---|---|
element | - | ((attributes: HTMLAttributes<"button">) => Element) | undefinedRender the element yourself |
CloseTrigger
Property | Default | Type |
---|---|---|
element | - | ((attributes: HTMLAttributes<"button">) => Element) | undefinedRender the element yourself |