Spawning Toasts
Much like modals, toasts are spawned with thetoast object’s methods:
- Replace the
cosmos-toastcomponent with your own custom element, or - Replace the properties of the
toastobject.
Error Link Toasts
Currently, the only special toast is thetoast.errorlink toast. It takes & a short message and
produces a toast with a link to spawn an error modal with the formatted error details.
Replacing the cosmos-toast component
Currently, the best way to create a uniform toast design is to replace the cosmos-toast
component with your own custom element.
cosmos-toast
and customize them to your liking.
Toasts come in 4 variants:
infosuccesswarningerror
lifespan.
Replacing the toast methods
Rather than exporting the Toast methods directly, exporting them under a toast object allows you
to replace the methods with your own custom ones. This allows you to integrate the Cosmos Components
with your own frontend framework. The info, success, warning, and error methods internally
call the toast.show method with the appropriate variant.
toast-shim.ts