Toast is not only a delicious breakfast food but also a simple, time limited notification. A toast message is a quick and easy way to alert a user that some action has occurred and after a certain amount of time has passed, the toast message will disappear.
Toasts are a simple, time dependent notification.
A rendered toast with body.
Toggle a toast via JavaScript by clicking the button below. It will slide up and fade in from the bottom of the page.
.toast-* or with toast options..toast-default will be applied to any unstyled toast.Toasts have three total styles available: .toast-default, .toast-round, and .toast-square.
Toasts have two optional sizes, available via modifier classes to be placed on a .toast-dialog.
For toasts that simply appear rather than fade in to view, remove the .fade class from your toast markup.
The toast plugin toggles your hidden content on demand, via data attributes or JavaScript. It also adds a .toast-backdrop to provide a click area for dismissing shown toasts when clicking outside the toast.
Activate a toast without writing JavaScript. Set data-toggle="toast" on a controller element, like a button, along with a data-target="#foo" or href="#foo" to target a specific toast to toggle.
Call a toast with id myToast with a single line of JavaScript:
Options can be passed via data attributes or JavaScript. For data attributes, append the option name to data-, as in data-backdrop="".
| Name | type | default | description |
|---|---|---|---|
| backdrop | boolean or the string 'static' |
true | Includes a toast-backdrop element. Alternatively, specify static for a backdrop which doesn't close the toast on click. |
| keyboard | boolean | true | Closes the toast when escape key is pressed. |
| show | boolean | true | Shows the toast when initialized. |
| style | string | 'default' | Styles the toast. Available styles: .toast-default, .toast-round, or .toast-square |
| timeout | number | 3000 | The amount of time to display the toast for before it dismisses itself. |
By adjusting the value for data-timeout, you can control how long the toast will stay visible for.
Activates your content as a toast. Accepts an optional options object.
Manually toggles a toast. Returns to the caller before the toast has actually been shown or hidden (i.e. before the shown.bs.toast or hidden.bs.toast event occurs).
Manually opens a toast. Returns to the caller before the toast has actually been shown (i.e. before the shown.bs.toast event occurs).
Manually hides a toast. Returns to the caller before the toast has actually been hidden (i.e. before the hidden.bs.toast event occurs).
Bootstrap's toast class exposes a few events for hooking into toast functionality.
All toast events are fired at the toast itself (i.e. at the <div class="toast">).
| Event type | description |
|---|---|
| show.bs.toast | This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event. |
| shown.bs.toast | This event is fired when the toast has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event. |
| hide.bs.toast | This event is fired immediately when the hide instance method has been called. |
| hidden.bs.toast | This event is fired when the toast has finished being hidden from the user (will wait for CSS transitions to complete). |