Skip to content
iv-ui v0.3.0

Alert

since 0.2.0

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

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

Types

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

Scheduled maintenance

The edge network is read-only on Sunday from 02:00 to 03:00 UTC.

Deploy complete

Version 0.2.0 is live in all three regions.

Token expires soon

The deploy token expires in six days.
Source· svelte Show Hide
<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>
  • 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.

Dismissible

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

New version available

Reload to pick up the latest build.
Source· svelte Show Hide
<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.

This project uses 92% of its monthly build minutes.
Source· svelte Show Hide
<script lang="ts">
	import { Alert } from '@elluzion/iv-ui';
</script>

<Alert type="warning">This project uses 92% of its monthly build minutes.</Alert>
import { Alert } from '@elluzion/iv-ui';

Props

4 props · 1 events · 1 snippets
PropTypeDefaultDescription
type 'info' | 'success' | 'warning' | 'error''info'Status family; controls the icon and color treatment.
title string''Short headline for the message.
dismissible booleanfalseShows a close button.
className string''Extra classes merged onto the root element.

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

Events

EventHandler typeDescription
ondismiss() => voidCalled when the close button is pressed.

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

Snippets

SnippetTypeDescription
childrenSnippetMessage body.
  • 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.
Class 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
iv-ui
↑ ↓ navigate ↵ open esc close minisearch · 482 records