---
title: "Alert"
description: "An inline message for information, success, warning, or error."
category: "Feedback & Status"
slug: alert
url: /components/alert
since: "0.2.0"
status: "stable"
---

# Alert

An inline message for information, success, warning, or error.

## Import

```svelte
import { Alert } from '@elluzion/iv-ui';
```

## Preview

Info, success, warning, and error share one layout.

```svelte
<script lang="ts">
	import { Alert } from '@elluzion/iv-ui';
</script>

<div class="stack">
	<Alert type="info" title="Scheduled maintenance">
		The edge network is read-only on Sunday from 02:00 to 03:00 UTC.
	</Alert>
	<Alert type="success" title="Deploy complete">Version 0.2.0 is live in all three regions.</Alert>
	<Alert type="warning" title="Token expires soon">The deploy token expires in six days.</Alert>
	<Alert type="error" title="Build failed">
		The type check reported two errors in the docs package.
	</Alert>
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		gap: var(--iv_spacing-md);
		width: 100%;
	}
</style>
```

## Usage

- `type` sets the icon and accent; `error` maps to `role="alert"`.
- `dismissible` adds a close button wired to `ondismiss`.
- Keep the body to a sentence or two; use `title` for the headline.

## Examples

### Dismissible

The close button calls `ondismiss`; the parent removes the alert.

```svelte
<script lang="ts">
	import { Alert, Button } from '@elluzion/iv-ui';

	let visible = $state(true);
</script>

<div class="stack">
	{#if visible}
		<Alert
			type="info"
			title="New version available"
			dismissible
			ondismiss={() => (visible = false)}
		>
			Reload to pick up the latest build.
		</Alert>
	{:else}
		<Button size="sm" variant="outline" onclick={() => (visible = true)}>Restore alert</Button>
	{/if}
</div>

<style>
	.stack {
		display: flex;
		flex-direction: column;
		align-items: start;
		gap: var(--iv_spacing-md);
		width: 100%;
	}
</style>
```

### Body only

A title is optional; children carry the message.

```svelte
<script lang="ts">
	import { Alert } from '@elluzion/iv-ui';
</script>

<Alert type="warning">This project uses 92% of its monthly build minutes.</Alert>
```

### Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `type` | `'info' \| 'success' \| 'warning' \| 'error'` | `'info'` | Status family; controls the icon and color treatment. |
| `title` | `string` | `''` | Short headline for the message. |
| `dismissible` | `boolean` | `false` | Shows a close button. |
| `className` | `string` | `''` | Extra classes merged onto the root element. |

`class`, `id`, `style`, `aria-*`, and `data-*` are forwarded through rest props.

### Events

| Event | Handler type | Description |
| --- | --- | --- |
| `dismiss` | `() => void` | Called when the close button is pressed. |

The legacy `on:name` form is accepted for every event.

### Snippets

| Snippet | Type | Description |
| --- | --- | --- |
| `children` | `Snippet` | Message body. |

### Tokens used

`--iv_border` · `--iv_error` · `--iv_error-surface` · `--iv_font-sans` · `--iv_font-ui` · `--iv_foreground` · `--iv_foreground-dim` · `--iv_info` · `--iv_info-surface` · `--iv_leading-base` · `--iv_leading-tight` · `--iv_outline-offset` · `--iv_outline-width` · `--iv_radius-sm` · `--iv_spacing-lg` · `--iv_spacing-md` · `--iv_spacing-sm` · `--iv_spacing-xl` · `--iv_success` · `--iv_success-surface` · `--iv_surface-overlay` · `--iv_surface-raised` · `--iv_text-body` · `--iv_text-sm` · `--iv_weight-semibold`

See the [token reference](/foundations/tokens.md) for values.

### CSS hooks

`.iv-alert` · `.iv-alert-body` · `.iv-alert-close` · `.iv-alert-content` · `.iv-alert-error` · `.iv-alert-icon` · `.iv-alert-info` · `.iv-alert-success` · `.iv-alert-title` · `.iv-alert-warning`

## Accessibility

- Error alerts use `role="alert"`; the other types use `role="status"`.
- The icon is decorative and hidden from assistive technology.
- The close button has an accessible name and a visible focus ring.

## Related

- [Toast](/components/toast.md)
- [EmptyState](/components/empty-state.md)
- [Badge](/components/badge.md)
- [Card](/components/card.md)