Skip to main content
Urbicon UI

Alert

Persistent inline notifications for status, warnings, errors, and informational messages with icons, actions, and dismissal.

Playground

Variant
Size
<Alert
  title="Heads up!"
>
  This is an alert with important information.
</Alert>

01 Examples

With Icon

Use the 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

Alerts can include action buttons for immediate user response.
<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

Click the close button to dismiss – click Reset to bring them back.
{#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

Use slotClasses to create eye-catching promotional banners.
<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

Translucent alerts over rich backgrounds.
<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

Developer-friendly alerts with a terminal aesthetic.
<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

Minimal left-border style that works well in content-heavy layouts.
<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

15 props
15 props
Prop
Type
Default
Description

05 Types

Local type definitions used by this component.

3 types
Name
Kind
Category
Used by
Description

06 Installation

Import

import { Alert } from '@urbicon-ui/blocks';