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