A succinct message that is displayed temporarily. Toasts are used to provide feedback to the user without interrupting their workflow.
1import { Button } from "@ngrok/mantle/button";2import { makeToast, Toast } from "@ngrok/mantle/toast";3 4// Only one <Toaster /> should be rendered at a time5// add it to the root of your app6<Toaster />7 8<Button9 type="button"10 onClick={() =>11 // make some toast! 🍞😋12 makeToast(13 <Toast.Root priority="success">14 <Toast.Icon />15 <Toast.Message>16 Laborum ea anim adipisicing in Lorem incididunt mollit ipsum reprehenderit.17 </Toast.Message>18 <Toast.Action asChild>19 <IconButton type="button" appearance="ghost" size="xs" icon={<XIcon />} label="Dismiss toast" />20 </Toast.Action>21 </Toast.Root>,22 )23 }24>25 Show Toast26</Button>The Toaster component renders all toasts. It accepts the following props:
The Toast.Root is the container for a toast message.
All props from div, plus:
The Toast.Icon displays an icon representing the toast priority. If no custom icon is provided, a default icon for the priority is used.
The Toast.Message contains the main text content of the toast.
All props from p, plus:
The Toast.Action is a button that dismisses the toast when clicked.
All props from button, plus:
Note: You can prevent the toast from being dismissed on click by calling event.preventDefault() in your onClick handler.
The makeToast function creates and displays a toast. It accepts the following parameters: