Alert
FeedbackA message in the page: <Alert.Root> (variant: default, info, success, warning, error) holds an optional icon first, an Alert.Title and an Alert.Description. The text stays readable on a tint of the status colour; the icon takes the colour. warning and error are role="alert", announced when they appear; the others role="status".
import { Alert } from '@limerdev/zest'; Use for
A message about the page or a form that stays until the situation changes: a failed save, an overdue payment, a read-only record.
Don't
A passing confirmation ("Saved"): use a toast. A question that needs an answer: use
AlertDialog. A field's error: use Field.Error.Examples
Variants
An icon, a title and a description, in each variant.
This invoice is read only
It was sent on 3 November. Credit it to make changes.
Reminders go out on Mondays
Payment received
4 200 kr from Acme AB on 12 November.
Due in two days
The invoice wasn't sent
The customer has no email address. Add one and send again.
<script lang="ts">
import { Alert } from '@limerdev/zest';
import CircleAlert from '@lucide/svelte/icons/circle-alert';
import CircleCheck from '@lucide/svelte/icons/circle-check';
import Info from '@lucide/svelte/icons/info';
import TriangleAlert from '@lucide/svelte/icons/triangle-alert';
</script>
<div class="grid w-full max-w-lg gap-3">
<Alert.Root>
<Info aria-hidden="true" />
<Alert.Title>This invoice is read only</Alert.Title>
<Alert.Description>It was sent on 3 November. Credit it to make changes.</Alert.Description>
</Alert.Root>
<Alert.Root variant="info">
<Info aria-hidden="true" />
<Alert.Title>Reminders go out on Mondays</Alert.Title>
</Alert.Root>
<Alert.Root variant="success">
<CircleCheck aria-hidden="true" />
<Alert.Title>Payment received</Alert.Title>
<Alert.Description>4 200 kr from Acme AB on 12 November.</Alert.Description>
</Alert.Root>
<Alert.Root variant="warning">
<TriangleAlert aria-hidden="true" />
<Alert.Title>Due in two days</Alert.Title>
</Alert.Root>
<Alert.Root variant="error">
<CircleAlert aria-hidden="true" />
<Alert.Title>The invoice wasn't sent</Alert.Title>
<Alert.Description>
The customer has no email address. <a href="#customer">Add one</a> and send again.
</Alert.Description>
</Alert.Root>
</div> Props
Every part also takes class (merged over its defaults), ref (bindable: the element), children, and child (a snippet that
renders your own element, with props to spread on it).
Alert.Root
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "error" | "default" | "info" | "success" | "warning" | 'default' | The kind of message, which sets its colour and its role (alert for warning and error, status for the rest). |
Alert.Title
No props of its own beyond the common ones.
Alert.Description
No props of its own beyond the common ones.