CodShot
HTML / Markup Public

Bootstrap Toast Notification

Show a Bootstrap 5 toast message from JavaScript.

#bootstrap #toast #ui #javascript
HTML / Markup
<button class="btn btn-primary" id="showToastBtn">Show toast</button>

<div class="toast-container position-fixed bottom-0 end-0 p-3">
    <div id="demoToast" class="toast" role="status" aria-live="polite" aria-atomic="true">
        <div class="toast-header">
            <strong class="me-auto">Saved</strong>
            <button type="button" class="btn-close" data-bs-dismiss="toast"></button>
        </div>
        <div class="toast-body">Your changes were saved successfully.</div>
    </div>
</div>

<script>
document.querySelector('#showToastBtn').addEventListener('click', () => {
    const toast = new bootstrap.Toast(document.querySelector('#demoToast'));
    toast.show();
});
</script>

Notes

Useful for short success and error messages after AJAX actions.

Snippet actions

CodShot user
CodShot user
Updated: 2026-06-08 14:33
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support