Compare commits

...
Sign in to create a new pull request.

5 commits

Author SHA1 Message Date
Patrick H. Lauke
07aebfde0f
Merge branch 'main' into live-toast 2021-01-14 08:41:35 +00:00
Mark Otto
f78ec2507b Fix placeholder image 2021-01-13 17:58:59 -08:00
Mark Otto
5f5be8a35c Triple backtick code 2021-01-13 17:54:48 -08:00
Mark Otto
5405da8a8a Add toast code to the snippet 2021-01-13 17:12:44 -08:00
Mark Otto
5f6dd9d881 Add a live toast example to the docs 2021-01-11 14:53:09 -08:00
2 changed files with 51 additions and 1 deletions

View file

@ -39,7 +39,7 @@
}) })
} }
document.querySelectorAll('.toast') document.querySelectorAll('.bd-example .toast')
.forEach(function (toastNode) { .forEach(function (toastNode) {
var toast = new bootstrap.Toast(toastNode, { var toast = new bootstrap.Toast(toastNode, {
autohide: false autohide: false
@ -48,6 +48,16 @@
toast.show() toast.show()
}) })
var toastTrigger = document.getElementById('liveToastBtn')
var toastLiveExample = document.getElementById('liveToast')
if (toastTrigger) {
toastTrigger.addEventListener('click', function () {
var toast = new bootstrap.Toast(toastLiveExample)
toast.show()
})
}
// Demos within modals // Demos within modals
document.querySelectorAll('.tooltip-test') document.querySelectorAll('.tooltip-test')
.forEach(function (tooltip) { .forEach(function (tooltip) {

View file

@ -41,6 +41,46 @@ Toasts are as flexible as you need and have very little required markup. At a mi
</div> </div>
{{< /example >}} {{< /example >}}
### Live
Click the button the below to show as toast (positioning with our utilities in the lower right corner) that has been hidden by default with `.hide`.
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 5">
<div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
{{< placeholder width="20" height="20" background="#007aff" class="rounded me-2" text="false" title="false" >}}
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
</div>
<div class="bd-example">
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
</div>
```html
<button type="button" class="btn btn-primary" id="liveToastBtn">Show live toast</button>
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 5">
<div id="liveToast" class="toast hide" role="alert" aria-live="assertive" aria-atomic="true">
<div class="toast-header">
<img src="..." class="rounded me-2" alt="...">
<strong class="me-auto">Bootstrap</strong>
<small>11 mins ago</small>
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
</div>
<div class="toast-body">
Hello, world! This is a toast message.
</div>
</div>
</div>
```
### Translucent ### Translucent
Toasts are slightly translucent, too, so they blend over whatever they might appear over. Toasts are slightly translucent, too, so they blend over whatever they might appear over.