@@ -272,6 +272,58 @@ When auto-hide is enabled, hovering over the toast will pause the auto-hide time
272272the toast, the auto-hide timer will be resumed. You can disable this feature by setting the
273273` no-hover-pause ` prop to ` true ` .
274274
275+ ### Close button
276+
277+ Toasts have a close button to hide them on use click by default. Setting the ` no-close-button ` prop
278+ to ` true ` will prevent this and creates a toast without the default close button.
279+
280+ It is still possible to create a custom close button for the toast by providing a unique ID and use
281+ the ` this.$bvToast.hide(id) ` method to hide the specific toast:
282+
283+ ``` html
284+ <template >
285+ <div >
286+ <b-button @click =" showToast" >Show Toast</b-button >
287+ </div >
288+ </template >
289+
290+ <script >
291+ export default {
292+ data () {
293+ return {
294+ count: 0
295+ }
296+ },
297+ methods: {
298+ showToast () {
299+ // Use a shorter name for `this.$createElement`
300+ const h = this .$createElement
301+ // Create a ID with a incremented count
302+ const id = ` my-toast-${ this .count ++ } `
303+
304+ // Create the custom close button
305+ const $closeButton = h (
306+ ' b-button' ,
307+ {
308+ on: { click : () => this .$bvToast .hide (id) }
309+ },
310+ ' Close'
311+ )
312+
313+ // Create the toast
314+ this .$bvToast .toast ([$closeButton], {
315+ id: id,
316+ title: ` Toast ${ this .count } ` ,
317+ noCloseButton: true
318+ })
319+ }
320+ }
321+ }
322+ </script >
323+
324+ <!-- toasts-advanced.vue -->
325+ ```
326+
275327### Toast roles
276328
277329Toasts are rendered with a default ` role ` attribute of ` 'alert' ` and ` aria-live ` attribute of
@@ -428,7 +480,7 @@ for generating more complex toast content:
428480``` html
429481<template >
430482 <div >
431- <b-button @click =" popToast " >Show Toast with custom content</b-button >
483+ <b-button @click =" showToast " >Show Toast with custom content</b-button >
432484 </div >
433485</template >
434486
@@ -440,7 +492,7 @@ for generating more complex toast content:
440492 }
441493 },
442494 methods: {
443- popToast () {
495+ showToast () {
444496 // Use a shorter name for this.$createElement
445497 const h = this .$createElement
446498 // Increment the toast count
0 commit comments