Nearby lessons

27 of 39

🔔 BS5 Toast

📌 What Are Bootstrap 5 Toasts?

Toasts are small notification panels (e.g. “Saved” or “Error”). Use .toast as the wrapper, optional .toast-header (with .btn-close and data-bs-dismiss="toast"), and .toast-body for the message. Show/hide via JavaScript: bootstrap.Toast.getOrCreateInstance(toastEl).show().

🔔 Toast Structure (.toast, .toast-header, .toast-body)

.toast – main container. .toast-header – top bar (title, time, close). .toast-body – message content. Use role="alert" and aria-live="assertive" for accessibility. Close button: .btn-close with data-bs-dismiss="toast".

🅱️

bootstrap Designer

Live Component Playground

html Source
Loading...
Built with Bootstrap 5.3 • Enterprise Ready

⏱️ Auto-hide (data-bs-autohide, data-bs-delay)

data-bs-autohide="true" (default) – toast hides after a delay. data-bs-delay="5000" – delay in milliseconds before auto-hide. Add to the .toast element.

🅱️

bootstrap Designer

Live Component Playground

html Source
Loading...
Built with Bootstrap 5.3 • Enterprise Ready

✅ Toast Best Practices

  • Use .toast-header and .toast-body for structure.
  • Show toasts with JS: bootstrap.Toast.getOrCreateInstance(el).show().
  • Use data-bs-delay to control auto-hide time.

🧠 Test Your Knowledge

3 Questions

Progress: 0 / 3
Keep Going!BS5 Scrollspy