xref: /openbmc/webui-vue/docs/guide/components/toasts/index.md (revision f6df801b384118b946bb3b7b3248832ec70cfd0a)
1*f6df801bSDerick Montague# Toasts
2*f6df801bSDerick MontagueUse a toast message to indicate the status of a user action. For example, a user saves a form successfully, a toast message with the `success` variant is displayed.  If the user action was not successful, a toast message with the `danger` variant is displayed.
3*f6df801bSDerick Montague
4*f6df801bSDerick MontagueThere are different transitions for the toast messages. The `success` toast message will auto-hide after 10 seconds. The user must manually dismiss the `informational`, `warning`, and `error` toast messages.  The `BVToastMixin` provides a simple API that generates a toast message that meets the transition guidelines.
5*f6df801bSDerick Montague
6*f6df801bSDerick Montague<img src="./toast.png" alt="Toast message examples" style="max-width:350px">
7*f6df801bSDerick Montague
8*f6df801bSDerick Montague```js{5}
9*f6df801bSDerick Montague// Sample method from Reboot BMC page
10*f6df801bSDerick MontaguerebootBmc() {
11*f6df801bSDerick Montague  this.$store
12*f6df801bSDerick Montague  .dispatch('controls/rebootBmc')
13*f6df801bSDerick Montague  .then(message => this.successToast(message))
14*f6df801bSDerick Montague  .catch(({ message }) => this.errorToast(message));
15*f6df801bSDerick Montague}
16*f6df801bSDerick Montague
17*f6df801bSDerick Montague// Methods used in this example
18*f6df801bSDerick Montaguemethods: {
19*f6df801bSDerick Montague  makeSuccessToast() {
20*f6df801bSDerick Montague    this.successToast('This is a success toast and will be dismissed after 10 seconds.');
21*f6df801bSDerick Montague  },
22*f6df801bSDerick Montague  makeErrorToast() {
23*f6df801bSDerick Montague    this.errorToast('This is an error toast and must be dismissed by the user.');
24*f6df801bSDerick Montague  },
25*f6df801bSDerick Montague  makeWarningToast() {
26*f6df801bSDerick Montague    this.warningToast('This is a warning toast and must be dismissed by the user.');
27*f6df801bSDerick Montague  },
28*f6df801bSDerick Montague  makeInfoToast() {
29*f6df801bSDerick Montague    this.infoToast('This is an info toast and must be dismissed by the user.');
30*f6df801bSDerick Montague  },
31*f6df801bSDerick Montague}
32*f6df801bSDerick Montague```