Alert
Persistent inline notifications for status, warnings, errors, and informational messages with icons, actions, and dismissal.
Playground
<Alert
title="Heads up!"
>
This is an alert with important information.
</Alert>01 Examples
With Icon
icon snippet to convey intent visually alongside the title and message.<Alert intent="success" title="Deployment complete">
{#snippet icon()}
<CheckCircleIcon class="h-5 w-5" />
{/snippet}
Build #347 deployed to production in 42 seconds.
</Alert>
<Alert intent="danger" title="Build failed">
{#snippet icon()}
<DangerCircleIcon class="h-5 w-5" />
{/snippet}
TypeScript compilation failed with 3 errors. Check the logs for details.
</Alert>With Actions
<Alert intent="warning" title="Unsaved changes">
{#snippet icon()}
<WarningTriangleIcon class="h-5 w-5" />
{/snippet}
You have unsaved changes that will be lost if you navigate away.
{#snippet actions()}
<Button size="sm" variant="ghost" intent="warning">Discard</Button>
<Button size="sm" variant="filled" intent="warning">Save now</Button>
{/snippet}
</Alert>
<Alert intent="danger" variant="inline" title="Delete workspace?">
This action cannot be undone. All projects and data will be permanently removed.
{#snippet actions()}
<Button size="sm" variant="ghost" intent="neutral">Cancel</Button>
<Button size="sm" variant="filled" intent="danger">Delete</Button>
{/snippet}
</Alert>Dismissible
{#if !dismissedSoft}
<Alert
intent="primary"
title="Welcome back!"
dismissible
onDismiss={() => (dismissedSoft = true)}
>
You have 5 unread notifications since your last visit.
</Alert>
{/if}
{#if !dismissedInline}
<Alert
intent="success"
variant="inline"
title="Trial activated"
dismissible
onDismiss={() => (dismissedInline = true)}
>
Your 14-day Pro trial starts now. No credit card required.
</Alert>
{/if}
{#if dismissedSoft || dismissedInline}
<Button
size="sm"
variant="ghost"
intent="neutral"
onclick={() => {
dismissedSoft = false;
dismissedInline = false;
}}
>
Reset dismissed alerts
</Button>
{/if}02 Customization
Gradient Banner
<Alert
title="🚀 New: AI Copilot"
slotClasses={{
base: 'bg-linear-to-r from-violet-600 to-indigo-600 text-white border-none shadow-lg shadow-violet-500/25',
title: 'text-white',
description: 'text-white/85'
}}
>
Intelligent code suggestions powered by your codebase context.
{#snippet actions()}
<Button
unstyled
class="rounded-lg bg-white/20 px-3 py-1.5 text-xs font-semibold text-white backdrop-blur-sm transition-all hover:bg-white/30"
>
Try it free
</Button>
{/snippet}
</Alert>
<Alert
title="🎉 Black Friday"
slotClasses={{
base: 'bg-linear-to-r from-amber-500 to-orange-500 text-white border-none shadow-lg shadow-amber-500/25',
title: 'text-white',
description: 'text-white/85'
}}
>
50% off all Pro plans. Offer ends Monday.
</Alert>Glassmorphism
<Alert
unstyled
title="Upload complete"
class="rounded-xl border border-white/20 bg-white/10 px-4 py-3 text-white backdrop-blur-xl"
slotClasses={{
title: 'font-semibold text-white',
description: 'text-sm text-white/75 mt-1'
}}
>
12 files processed successfully.
</Alert>
<Alert
unstyled
title="Connection lost"
class="rounded-xl border border-white/20 bg-white/10 px-4 py-3 text-white backdrop-blur-xl"
slotClasses={{
title: 'font-semibold text-white',
description: 'text-sm text-white/75 mt-1'
}}
dismissible
>
Reconnecting automatically…
</Alert>Terminal / Monospace
<Alert
unstyled
class="flex gap-3 rounded-none border-l-4 border-emerald-500 bg-neutral-950 px-4 py-3 font-mono"
slotClasses={{
title: 'text-sm font-bold text-emerald-400',
description: 'text-xs text-neutral-400 mt-1'
}}
title="[OK] Build succeeded"
>
Compiled 847 modules in 1.2s · 0 warnings · 0 errors
</Alert>
<Alert
unstyled
class="flex gap-3 rounded-none border-l-4 border-red-500 bg-neutral-950 px-4 py-3 font-mono"
slotClasses={{
title: 'text-sm font-bold text-red-400',
description: 'text-xs text-neutral-400 mt-1'
}}
title="[ERR] Process exited"
>
SIGTERM received · pid 4821 · exit code 137
</Alert>Accent Border
v1 API will be removed in the next major release. Migrate to v2 before
March 2026.<Alert
unstyled
class="border-primary bg-surface-elevated rounded-modify flex gap-3 border-l-4 px-4 py-3"
slotClasses={{
title: 'text-sm font-semibold text-text-primary',
description: 'text-sm text-text-secondary mt-0.5'
}}
title="Tip"
>
Use keyboard shortcuts to speed up your workflow. Press <Kbd keys="⌘K" /> to open the command
palette.
</Alert>
<Alert
unstyled
class="border-warning bg-surface-elevated rounded-modify flex gap-3 border-l-4 px-4 py-3"
slotClasses={{
title: 'text-sm font-semibold text-text-primary',
description: 'text-sm text-text-secondary mt-0.5'
}}
title="Deprecation notice"
>
The <code class="text-text-primary bg-surface-base rounded px-1 py-0.5 text-xs">v1</code>
API will be removed in the next major release. Migrate to
<code class="text-text-primary bg-surface-base rounded-modify px-1 py-0.5 text-xs">v2</code> before
March 2026.
</Alert>Recurring promotional looks like the gradient banners belong in a BlocksProvider preset (presets.Alert): registered once, applied per instance via preset —
instead of repeating slotClasses at every call site.
See Customization.
03 Accessibility
Built-in ARIA
Renders with role="alert", ensuring screen readers
announce the content as a live region. Dismissible alerts include a close button with aria-label="Dismiss".
Keyboard
The dismiss button is focusable via Tab and activates with Enter / Space. Focus-visible ring follows the component's intent color for clear contrast.
Reduced Motion
Transition durations use the --blocks-duration-fast token, which is automatically shortened when prefers-reduced-motion is enabled.
04 API Reference
Prop | Type | Default | Description | |
|---|---|---|---|---|
actions | Snippet | — | Action buttons snippet | |
children | Snippet | — | Description content (children slot) | |
class | string | — | Additional CSS classes to apply to the Alert component | |
dismissible | boolean | false | Show dismiss/close button | |
icon | Snippet | — | Custom icon snippet (replaces default intent icon) | |
intent | primaryinfosuccesswarning +2 more | 'primary' | Semantic color intent | |
onDismiss | () => void | — | Callback when dismissed | |
preset | string | — | Apply a named preset registered via <BlocksProvider presets={{ Alert: {...} }}>.
Prefer this over class overrides when the requested look falls outside the
semantic intent palette — presets keep hover/active/dark-mode logic coherent
and make the custom look reusable across the project. | |
size | smmdlg | 'md' | Size variant that controls dimensions and spacing of the Alert | |
slotClasses | Partial<Record<AlertSlots, string>> | — | Per-slot class overrides. Slots: base | icon | content | title | description | actions | dismissButton | |
title | string | — | Alert title (bold header text) | |
unstyled | boolean | — | Remove default styles | |
variant | softinlinefilled | 'soft' | Visual style variant for the Alert component | |
...AlertVariants variant | VariantProps | — | Styling variants from AlertVariants | |
...HTMLAttributes<HTMLDivElement> inherited | HTMLAttributes | — | HTML attributes (excluding: 'title' | 'children') |
05 Types
Local type definitions used by this component.
Name | Kind | Category | Used by | Description | |
|---|---|---|---|---|---|
AlertProps | interface | props | 0 | Props interface for Alert component | |
AlertVariants | type | variant | 1 | — | |
AlertSlots | type | variant | 0 | Slot names derived from the tv() config — single source of truth for slotClasses. |
06 Installation
Import
import { Alert } from '@urbicon-ui/blocks';