TOAST: Lightweight confirmation messages that appear after user actions
POSITIONING: Bottom-center, slides up from bottom edge
CLASSES: .tw-toast .tw-toast-container .tw-toast-visible .tw-toast-dismissing .tw-toast-success .tw-toast-error .tw-toast-warning .tw-toast-info .tw-toast-icon .tw-toast-message .tw-toast-action .tw-toast-close
Toasts provide quick, non-blocking confirmations (e.g., "Copied!", "Saved!", "Undo available"). Auto-dismiss after 3 seconds (6s with action), pause-on-hover supported. Dark background with semantic color via icon only.
Minimal Structure: Icon + message in dark container. White text ensures readability.
<div class="tw-toast tw-toast-visible">
<i class="fa-solid fa-check tw-toast-icon"></i>
<span class="tw-toast-message">Changes saved successfully</span>
</div>
Icon Color Only: Dark background remains consistent. Add .tw-toast-success, .tw-toast-error, .tw-toast-warning, or .tw-toast-info to color the icon.
<div class="tw-toast tw-toast-success tw-toast-visible">...</div>
<div class="tw-toast tw-toast-error tw-toast-visible">...</div>
<div class="tw-toast tw-toast-warning tw-toast-visible">...</div>
<div class="tw-toast tw-toast-info tw-toast-visible">...</div>
Manual Dismiss: Add .tw-toast-close button for user-controlled dismissal. Still auto-dismisses unless disabled.
<div class="tw-toast tw-toast-visible">
<i class="fa-solid fa-check tw-toast-icon"></i>
<span class="tw-toast-message">Email copied to clipboard</span>
<button type="button" class="tw-toast-close" aria-label="Dismiss">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
Actionable: Add .toast-action link/button for quick actions (e.g., "Undo", "View"). Auto-dismiss extends to 6 seconds when action is present.
<div class="tw-toast tw-toast-visible">
<i class="fa-solid fa-trash tw-toast-icon"></i>
<span class="tw-toast-message">3 items deleted</span>
<button type="button" class="tw-toast-action">Undo</button>
</div>
Auto-dismiss Only: Omit close button for brief confirmations that should disappear automatically.
<div class="tw-toast tw-toast-success tw-toast-visible">
<i class="fa-solid fa-circle-check tw-toast-icon"></i>
<span class="tw-toast-message">Link copied!</span>
</div>
Multiple Toasts: Container uses flex-col-reverse so newer toasts appear above older ones. Each auto-dismisses independently.
<div class="tw-toast-container">
<!-- Newer toasts appear above older ones -->
<div class="tw-toast tw-toast-visible">...</div>
<div class="tw-toast tw-toast-visible">...</div>
<div class="tw-toast tw-toast-visible">...</div>
</div>
Live Controller: Click buttons below to spawn toasts with Stimulus controller. Features auto-dismiss (3s default, 6s with action), pause-on-hover, manual dismiss via close button, and Escape key support.
Interactions: Hover to pause auto-dismiss • Click X to close • Press Escape to dismiss topmost
Duration: 3s default • 6s with action button • Disabled when data-auto-dismiss="0"
<div data-controller="toast">
<div class="tw-toast-container">
<div class="tw-toast" data-toast-target="toast" role="status" aria-live="polite">
<i class="fa-solid fa-check tw-toast-icon"></i>
<span class="tw-toast-message">Changes saved</span>
<button type="button" class="tw-toast-close" data-action="click->toast#dismiss">
<i class="fa-solid fa-xmark"></i>
</button>
</div>
</div>
</div>
ARIA Attributes:
role="status" on toast elementaria-live="polite" announces to screen readers without interruptingaria-label="Dismiss" on close button for icon-only contextKeyboard Support:
Motion: Animation respects prefers-reduced-motion — transitions disabled when user prefers reduced motion.