This is documentation for Admin UI 0.132.0, which is no longer actively maintained.
For up-to-date documentation, see the latest version (0.136.0).
Version: 0.132.0
Toast
The toast is used to show alerts on top of an overlay. The toast will close itself when the dismiss button is clicked, or after a timeout. The toast component is used to give feedback to users after an action has taken place.
import{ToastProvider, useToast, createSystem }from'@vtex/admin-ui' const[SystemProvider]=createSystem() // You must always add the ToastProvider in the root of your application functionRoot(){ return( <SystemProvider> <ToastProvider> {...} </ToastProvider> </SystemProvider> ) } functionExample(){ const showToast =useToast() return( <Button onClick={()=> showToast({ message:'This is the admin-ui toast!', }) } > Show Toast </Button> ) }
Because the way of rendering a Toast on admin-ui is by calling the function returned by the useToast hook, these are the properties that you can pass to the function returned params.
Name
Type
Description
Required
Default
message
ReactNode
Message displayed to the end-user.
✅
-
tone
critical, info, warning, positive
The toast's tone of voice.
🚫
info
duration
number
How long the toast should be apparent, in milliseconds.
Conceptually, a toast is a type of alert, that gives users instant feedback about the tasks they just did. Its main objective is to ensure tasks confirmation and success.
Keep copies short and straight-forward. A single sentence should be enough.
Toasts shouldn’t be used only for neutral or positive feedback. System errors also apply.
Follow the semantics used by icons as described below.
Follow the same lead of Alerts to determine the type.
Animation should pop from the bottom of the screen and rest on the lower right-hand corner.