Alert
Inline feedback banners for important messages.
Basic
Preview
This is a default alert message.
<div class="alert">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" /></svg>
<span>This is a default alert message.</span>
</div> Requires: ux.min.css
<div class="flex items-start gap-3 w-full rounded-2xl p-4 bg-base-200 text-base-content text-sm">
<svg class="size-5 shrink-0 mt-0.5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" /></svg>
<span>This is a default alert message.</span>
</div> Requires: tw.min.css
// No JavaScript required - pure CSS component
// To dismiss: remove the element or toggle display Colors
Preview
Info — something you should know.
Success — operation completed!
Warning — please review before continuing.
Error — something went wrong.
<div class="alert color-info">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" /></svg>
<span>Info — something you should know.</span>
</div>
<div class="alert color-success">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>
<span>Success — operation completed!</span>
</div>
<div class="alert color-warning">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>
<span>Warning — please review before continuing.</span>
</div>
<div class="alert color-error">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z" /></svg>
<span>Error — something went wrong.</span>
</div> Requires: ux.min.css
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-info/12 text-base-content border border-info/30">
<svg class="size-5 shrink-0 mt-0.5 text-info" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" /></svg>
<span>Info — something you should know.</span>
</div>
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-success/12 text-base-content border border-success/30">
<svg class="size-5 shrink-0 mt-0.5 text-success" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>
<span>Success — operation completed!</span>
</div>
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-warning/12 text-base-content border border-warning/30">
<svg class="size-5 shrink-0 mt-0.5 text-warning" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>
<span>Warning — please review before continuing.</span>
</div>
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-error/12 text-base-content border border-error/30">
<svg class="size-5 shrink-0 mt-0.5 text-error" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z" /></svg>
<span>Error — something went wrong.</span>
</div> Requires: tw.min.css
// No JavaScript required - pure CSS component With Title & Description
Preview
Payment successful
Your payment of $49.99 has been processed.
<div class="alert color-success">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>
<div class="alert-content">
<div class="alert-title">Payment successful</div>
<div class="alert-description">Your payment of $49.99 has been processed.</div>
</div>
<button class="alert-close">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /></svg>
</button>
</div> Requires: ux.min.css
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-success/12 text-base-content border border-success/30">
<svg class="size-5 shrink-0 mt-0.5 text-success" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75 11.25 15 15 9.75M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" /></svg>
<div class="flex-1 min-w-0">
<div class="font-semibold mb-0.5">Payment successful</div>
<div class="text-sm opacity-80">Your payment of $49.99 has been processed.</div>
</div>
<button class="inline-flex items-center justify-center size-6 rounded-lg border-none cursor-pointer bg-transparent opacity-50 hover:opacity-100">
<svg class="size-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" /></svg>
</button>
</div> Requires: tw.min.css
// Dismiss alert on close button click
document.querySelector('.alert-close').addEventListener('click', function() {
this.closest('.alert').remove();
}); Filled
Preview
Solid info alert with filled background.
Solid error alert with filled background.
<div class="alert alert-filled color-info">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" /></svg>
<span>Solid info alert with filled background.</span>
</div>
<div class="alert alert-filled color-error">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z" /></svg>
<span>Solid error alert with filled background.</span>
</div> Requires: ux.min.css
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-info text-info-content">
<svg class="size-5 shrink-0 mt-0.5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" /></svg>
<span>Solid info alert with filled background.</span>
</div>
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-error text-error-content">
<svg class="size-5 shrink-0 mt-0.5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9 3.75h.008v.008H12v-.008Z" /></svg>
<span>Solid error alert with filled background.</span>
</div> Requires: tw.min.css
// No JavaScript required - pure CSS component Outline
Preview
Outline warning alert with border only.
<div class="alert alert-outline color-warning">
<svg class="alert-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>
<span>Outline warning alert with border only.</span>
</div> Requires: ux.min.css
<div class="flex items-start gap-3 w-full rounded-2xl p-4 text-sm bg-transparent text-base-content border border-warning">
<svg class="size-5 shrink-0 mt-0.5 text-warning" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" /></svg>
<span>Outline warning alert with border only.</span>
</div> Requires: tw.min.css
// No JavaScript required - pure CSS component Classes Reference
| Class | Description |
|---|---|
| .alert | Base alert container |
| .alert-soft | Tinted background, no border |
| .alert-outline | Transparent background, colored border |
| .alert-filled | Solid color background |
| .alert-compact | Reduced padding, center-aligned |
| .alert-icon | Icon element (20px) |
| .alert-content | Content wrapper |
| .alert-title | Alert heading text |
| .alert-description | Alert body text |
| .alert-close | Dismiss button |
| .alert-actions | Action buttons container |