1# Toasts
2Use a toast message to indicate the status of a user action. For example, a user
3saves a form successfully, a toast message with the `success` variant is
4displayed.  If the user action was not successful, a toast message with the
5`danger` variant is displayed.
6
7There are different transitions for the toast messages. The `success` toast
8message will auto-hide after 10 seconds. The user must manually dismiss the
9`informational`, `warning`, and `error` toast messages.  The `BVToastMixin`
10provides a simple API that generates a toast message that meets the transition
11guidelines.
12
13<img src="./toast.png" alt="Toast message examples" style="max-width:350px">
14
15```js{5}
16// Sample method from Reboot BMC page
17rebootBmc() {
18  this.$store
19  .dispatch('controls/rebootBmc')
20  .then(message => this.successToast(message))
21  .catch(({ message }) => this.errorToast(message));
22}
23
24// Methods used in this example
25methods: {
26  makeSuccessToast() {
27    this.successToast('This is a success toast and will be dismissed after 10 seconds.');
28  },
29  makeErrorToast() {
30    this.errorToast('This is an error toast and must be dismissed by the user.');
31  },
32  makeWarningToast() {
33    this.warningToast('This is a warning toast and must be dismissed by the user.');
34  },
35  makeInfoToast() {
36    this.infoToast('This is an info toast and must be dismissed by the user.');
37  },
38}
39```
40
41## Additional options
42
43The first argument for each method will be the toast body content. It accepts a
44string value or an array of strings for toasts needing to display multiple lines
45of content.
46
47The BVToastMixin also accepts additional options as a second argument. Pass an
48object with a `title` property to change the default toast title. Include a
49`refreshAction` property, set to true, to include a link that refreshes the
50application. Include a `timestamp` property, set to true, to include a timestamp
51in the toast.
52
53<img src="./toast-options.png" alt="Toast message options example"
54style="max-width:350px">
55
56```js
57
58methods: {
59  makeInfoToast() {
60    this.infoToast([
61      'This is a toast with multi-lined body content.',
62      'Just pass an array of strings!'
63      ], {
64      title: 'This is an example',
65      refreshAction: true,
66      timestamp: true
67    })
68  }
69}
70```