Bridge UI

Alert

Alert banner for brief feedback messages without interrupting the user.

Introduction

Alerts give users brief, potentially time-sensitive information in an unobtrusive manner. Use them for inline feedback within a page—success confirmations, warnings about a form field, or informational notices about a section.

When to use

Use Alert for persistent, in-page feedback the user should read. Prefer Snackbar for transient toasts and Badge for compact status labels.

When to use: Place alerts near the content they describe so users encounter the message in context. Alerts should not interrupt the user’s flow—they remain in the layout rather than blocking interaction.

Compared to similar components:

  • Snackbar — Toast notifications portaled to the viewport. Use Snackbar for transient, global feedback that auto-dismisses (e.g. “Item saved”). Use Alert for persistent, in-context messages tied to a specific area of the page.
  • Modal — Blocks interaction until dismissed. Alerts are informational only; use a Modal when you need the user to confirm or respond before continuing.

Use the framework selector in the site header to switch between React and Vue.

Import

import { Alert } from "@bridge-ui/vue/Components/Alert";
import { Alert } from "@bridge-ui/react/Components/Alert";

Basic usage

The Alert component wraps its content and stretches to fill its container. Provide a title for the heading and use children (or the default slot in Vue) for the body message.

Colors

Use the color prop to convey the semantic meaning of the message. Available colors: primary, secondary, success, info, warning, error, and dark.

Variants

The Alert component supports three style variants, set with the variant prop:

  • flat (default) — subtle background tint
  • solid — filled background with contrasting text
  • outline — transparent background with a colored border

Rounded

Use the rounded prop to control border radius. Available values: none, xs, sm, md, lg, xl, 2xl, 3xl, 4xl, and full (defaults vary by component).

Actions

Add an action aligned to the right of the title row. In React, use the slots.action prop; in Vue, use the #action slot. This is useful for dismiss buttons, undo links, or other quick responses.

The footer slot renders below the body with top border spacing. Use it for secondary actions such as Cancel and Confirm buttons.

Icons

Each color comes with a default icon. Override it with the icon prop (an icon component or semantic name), or pass null to hide the icon entirely.

Customization

Fine-tune appearance with rounded, shadow, padding, and the classes prop to target individual parts (root, title, body, icon).

Accessibility

Alert does not set role or aria-live by default—you choose the appropriate level of urgency:

  • Urgent dynamic messages: pass role="alert" on the root (equivalent to aria-live="assertive" and aria-atomic="true"). Screen readers announce these immediately. Use sparingly for critical errors or time-sensitive warnings.
  • Non-interrupting updates: pass role="status" and aria-live="polite" for softer confirmations or background status changes.

Additional guidelines:

  • Alerts should not steal keyboard focus when they appear.
  • If an alert contains an action (via slots.action or #action), ensure interactive elements remain reachable by keyboard (tabindex="0" or native focusable elements).
  • Essential alerts should not disappear automatically—timed removal can make content inaccessible to users who need more time.
  • Dynamically inserted alerts are announced by screen readers; alerts present on initial page load are not.
  • Do not rely on color alone to convey meaning—include the message in the alert text or title.

Use customProps (React) or custom-props (Vue) to forward attributes to internal parts without affecting the root element.

Anatomy

The Alert component renders a root <div> containing a title row (icon, title, optional action), an optional body, and an optional footer:

<div class="alert-root">
  <!-- optional header slot -->
  <div class="flex items-start justify-between">
    <div class="flex items-start gap-x-3">
      <svg class="alert-icon"><!-- icon --></svg>
      <div class="alert-title">Alert title</div>
    </div>
    <div><!-- action slot --></div>
  </div>
  <div class="alert-body">Message content</div>
  <!-- footer slot -->
</div>

Button, Icon, Snackbar

API

Prop Type Default Description
title string The alert heading.
color AlertColor "primary" Semantic color of the alert.
variant AlertVariant "flat" Visual style variant.
icon IconSource | null Custom icon or null to hide.
padding AlertPadding "medium" Internal padding.
rounded AlertRounded "sm" Border radius.
shadow AlertShadow "sm" Box shadow.
classes { root?, title?, body?, icon? } Class overrides per part.
customProps { root?, title?, body?, icon? } HTML attributes forwarded to each part (HTMLAttributes).
slots { action?, footer?, header?, icon?, title? } React slots. Vue: #action, #footer, #header, #icon, #title.