Component
Minimal Toast
Compact pill-shaped toast for terse, icon-led feedback like "Copied!" or "Saved". No body text — just an icon and a label. Appears centered at the bottom and fades after 2 seconds.
- Component
- Tailwind
- HTML
- MIT
Preview
Live component
9:41 100%
devsnips.dev/library/tailwind/components/toasts/minimal-toast/ fluid · no fixed width 100%
Install
Add to your project
npx devsnips add Tailwind/Components/Toasts/minimal-toast Tailwind/Components/Toasts/minimal-toast <!--
Snippet Name: Minimal Toast
Description: Compact, icon-led toast for terse feedback ("Copied!", "Saved"). No body text — just an icon, a label, and an optional close button.
Author: DevSnips Contributors
Usage Example: Call showToast('Copied!') after a clipboard copy or quick inline action.
-->
<div
id="minimal-toast-region"
class="pointer-events-none fixed bottom-4 left-1/2 z-50 flex -translate-x-1/2 flex-col items-center gap-3"
role="region"
aria-label="Notifications"
aria-live="polite"
data-toast-region
></div>
<!-- Demo trigger button -->
<button onclick="showToast('Copied!')" class="inline-flex items-center gap-2 rounded-xl border border-gray-200 bg-white px-5 py-2.5 text-sm font-semibold text-gray-700 shadow-sm transition-colors hover:bg-gray-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2">
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/></svg>
Copy to clipboard
</button>
<script>
(function () {
const root = document.currentScript.closest('[data-toast-region]');
if (!root) return;
function dismiss(toast) {
if (!toast || toast.dataset.dismissed === 'true') return;
toast.dataset.dismissed = 'true';
toast.classList.add('opacity-0', 'translate-y-2');
toast.addEventListener('transitionend', () => toast.remove(), { once: true });
setTimeout(() => toast.remove(), 300);
}
function showToast(label) {
const toast = document.createElement('div');
toast.className = 'toast-item pointer-events-auto inline-flex items-center gap-2 rounded-full bg-gray-900 py-2 pl-2.5 pr-4 text-sm font-medium text-white shadow-lg transition duration-300 ease-out';
toast.setAttribute('role', 'status');
toast.innerHTML = `
<span class="flex h-6 w-6 items-center justify-center rounded-full bg-green-500/20 text-green-400">
<svg class="h-4 w-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2.5" d="M5 13l4 4L19 7"/></svg>
</span>
<span>${label || 'Done'}</span>`;
root.appendChild(toast);
const timer = setTimeout(() => dismiss(toast), 2000);
toast.addEventListener('mouseenter', () => clearTimeout(timer));
}
window.showToast = showToast;
})();
</script> # Minimal Toast
Minimal toast notification.
## Usage
```bash
npx devsnips add Tailwind/Components/Toasts/minimal-toast
```
Copy from `code.html`.
## File Structure
`code.html` · `preview.html` · `metadata.json` · `README.md` 53 lines UTF-8 · LF · Spaces: 2
Continue browsing