Alert
A status banner with variants, dismiss action, and optional action slot.
Rendering Alert…
Installation
Copy the source into your project with the CLI. It lands under @/components/ui and is yours to edit.
npx mlola-ui add alertUsage
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
export default function Example() {
return (
<Alert tone="warning">
<AlertTitle>Your card expires soon</AlertTitle>
<AlertDescription>Update it before September 30 to keep your plan.</AlertDescription>
</Alert>
);
}Styling comes from the engine stylesheet and the nearest theme. Set it once at the root:
<html data-theme="graphite" data-mode="light">Examples
With an action, dismissible
An alert can offer the fix and step aside once it is read.
Rendering With an action, dismissible…
Soft, inside a form
The soft variant sits quietly among fields without a heading.
Rendering Soft, inside a form…
HTML
The markup the example above renders, exactly. It needs no script: write it from any language or template.
<div class="ml-alert" role="alert" data-tone="warning" data-variant="card" data-state="open">
<span class="ml-alert-icon" aria-hidden="true"><svg class="mlola-glyph" width="1em" height="1em" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="var(--mlola-glyph-stroke, var(--ml-icon-stroke, 1.75))" stroke-linecap="round" stroke-linejoin="round" focusable="false" aria-hidden="true" data-optical-size="default" style="color:var(--mlola-glyph-color, currentColor);scale:var(--mlola-glyph-optical-scale, 1);transform-origin:center"><path d="m10.3 3.8-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.7-3.2l-8-14a2 2 0 0 0-3.4 0Z" pathLength="1"></path><path d="M12 9v4M12 17h.01" pathLength="1"></path></svg></span>
<div class="ml-alert-content">
<p class="ml-alert-title">Your card expires soon</p>
<div class="ml-alert-description">Update it before September 30 to keep your plan.</div>
</div>
</div>Options
| Prop | Values | Default |
|---|---|---|
tone | neutralinfosuccesswarningdanger | neutral |
variant | cardsoft | card |
Every prop with a fixed set of values, read from the exported TypeScript types with its doc comment. Open the Code tab above for the rest of the API.
Classes and attributes
A class names each element; data-* and aria-* attributes carry its variant and state. The values listed are the ones the stylesheet draws; the default needs no attribute.
| Class | Attributes |
|---|---|
ml-alert | data-state="closing"data-tone="danger | info | neutral | success | warning"data-variant="soft" |
ml-alert-title | — |
ml-alert-icon | — |
ml-alert-content | — |
ml-alert-description | — |
ml-alert-actions | — |
ml-alert-dismiss | — |
Accessibility and theming
- Semantic elements, accessible names and state relationships are part of the contract.
- Keyboard, pointer and touch paths are operable; focus stays visible in every theme.
- Light and dark modes pass WCAG AA contrast in all 5 canonical themes.
- Reduced motion and forced colors keep meaning and operation.
Dependencies
Installed alongside this component. No third-party UI runtime is ever added.
@mlola-ui/icons