> ## Documentation Index
> Fetch the complete documentation index at: https://www.beeq.design/llms.txt
> Use this file to discover all available pages before exploring further.

# Alert

> Alert conveys status, progress, or required next steps to the user in a clear, contextual message.

![BEEQ Alert component overview](https://mintcdn.com/beeq/q2QfdaQVx7Z_gV2t/components/images/alert/alert-overview-light.svg?fit=max\&auto=format\&n=q2QfdaQVx7Z_gV2t\&q=85\&s=716c2535c4b3db6e56949ce72bf6b006)

Alert component overview

Alert is a lightweight message surface for conveying status, progress, or required next steps in a clear and consistent way.

## When to use

> [card]
>
> Use alerts when
>
> * You need to clearly and concisely convey important information
> * A message applies to a page, card, section, or system-level state
> * Users need feedback after submitting data, changing permissions, or completing an action
> * Users need to know about errors, warnings, maintenance, upgrades, or time-sensitive tasks

> [card]
>
> Do not use alerts when
>
> * The alert would disrupt a critical task
> * The message overlaps essential content or important interface controls
> * Its presence could confuse users or compete with a more relevant inline message
> * A toast, notification, or field-level validation message would be more precise
> * Content failed to load and the region has nothing else to show; use an [Empty state](https://www.beeq.design/components/empty-state.md) with a retry action instead

> [!TIP]
>
> Choose [`bq-alert`](https://www.beeq.design/components/alert) for a message tied to a page or section that stays in the document flow, [`bq-notification`](https://www.beeq.design/components/notification) for a system message with a description or actions that stacks at the edge of the screen, and [`bq-toast`](https://www.beeq.design/components/toast) for a short status message with no actions that disappears on its own.

## Patterns

Alerts can be used at different scopes, depending on what the message affects.

![Global alert](https://www.beeq.design/components/images/alert/alert-placement-global-light.svg)
![Global alert](https://www.beeq.design/components/images/alert/alert-placement-global-dark.svg)

## Global alert

Use a global alert for messages that affect the full experience. Place it directly below the navigation.

![Page alert](https://www.beeq.design/components/images/alert/alert-placement-page-light.svg)
![Page alert](https://www.beeq.design/components/images/alert/alert-placement-page-dark.svg)

## Page alert

Use a page alert when the message applies to the page as a whole, such as a loading failure or permission issue.

![Section or card alert](https://www.beeq.design/components/images/alert/alert-placement-card-light.svg)
![Section or card alert](https://www.beeq.design/components/images/alert/alert-placement-card-dark.svg)

## Section or card alert

Place alerts close to the affected section so users can connect the message with the content it describes.

![Custom alert](https://www.beeq.design/components/images/alert/alert-placement-custom-light.svg)
![Custom alert](https://www.beeq.design/components/images/alert/alert-placement-custom-dark.svg)

## Custom alert

Use custom icons and CSS variables when a message has no built-in severity, but keep color and icon choices consistent.

## Anatomy

![BEEQ Alert component anatomy](https://mintcdn.com/beeq/q2QfdaQVx7Z_gV2t/components/images/alert/alert-anatomy-light.svg?fit=max\&auto=format\&n=q2QfdaQVx7Z_gV2t\&q=85\&s=29dc35102dc952779a66b3468759f104)

Alert component anatomy

| Part | Element | Description |
| - | - | - |
| **1** | Container | The alert surface that groups the message, icon, title, and actions |
| **2** | Icon | Status icon, or a custom icon when the alert uses the `default` type |
| **3** | Title | The alert title content in the default slot |
| **4** | Close button | Dismisses the alert unless `disable-close` is set |
| **5** | Description | Optional supporting content in the `body` slot |
| **6** | CTA button | Optional action content in the `footer` slot |

## Design guidelines

### Types

![Basic](https://www.beeq.design/components/images/alert/alert-type-basic-light.svg)
![Basic](https://www.beeq.design/components/images/alert/alert-type-basic-dark.svg)

## Basic

Use a basic alert when a short title gives users enough context to understand the message.

![With description](https://www.beeq.design/components/images/alert/alert-type-description-light.svg)
![With description](https://www.beeq.design/components/images/alert/alert-type-description-dark.svg)

## With description

Add a description when users need supporting detail, recovery guidance, or a link to the next step.

![With button](https://www.beeq.design/components/images/alert/alert-type-button-light.svg)
![With button](https://www.beeq.design/components/images/alert/alert-type-button-dark.svg)

## With button

Include an action when the alert asks users to resolve the message or view related details.

![With description and footer actions](https://www.beeq.design/components/images/alert/alert-type-footer-light.svg)
![With description and footer actions](https://www.beeq.design/components/images/alert/alert-type-footer-dark.svg)

## With description and footer actions

Place actions in the footer when users need to compare or choose between multiple next steps.

> [!NOTE]
>
> Set `border` to match the surface where the alert appears. Use the same radius scale as the surrounding layout.

## Usage

**Allowed `type` values:** `default` (default), `info`, `success`, `warning`, `error`. Only `info`, `success`, `warning` and `error` render a predefined status icon; `default` renders the `icon` slot content only.

**Allowed `border` values:** `none`, `xs2`, `xs`, `s` (default), `m`, `l`, `full`.

### Default

Use the `default` variant for general-purpose alerts. It lets you customize the `bq-icon` for messages with no associated severity.

> [!TIP]
>
> Set `open` to show the alert. Use `show()` and `hide()` when visibility is controlled programmatically.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-alert open>
  <bq-icon name="star" slot="icon"></bq-icon>
  Title
</bq-alert>

<bq-alert open>
  <bq-icon name="star" slot="icon"></bq-icon>
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
</bq-alert>

<bq-alert open>
  <bq-icon name="star" slot="icon"></bq-icon>
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
  <div slot="footer">
    <bq-button size="small">Button</bq-button>
    <bq-button appearance="link" size="small">Button</bq-button>
  </div>
</bq-alert>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { BqAlert, BqButton, BqIcon } from "@beeq/react";

<>
  <BqAlert open>
    <BqIcon name="star" slot="icon" />
    Title
  </BqAlert>

  <BqAlert open>
    <BqIcon name="star" slot="icon" />
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open>
    <BqIcon name="star" slot="icon" />
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqAlert, BqIcon, BqButton } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqAlert, BqIcon, BqButton],
  template: `
    <bq-alert open>
      <bq-icon name="star" slot="icon"></bq-icon>
      Title
    </bq-alert>

    <bq-alert open>
      <bq-icon name="star" slot="icon"></bq-icon>
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
    </bq-alert>

    <bq-alert open>
      <bq-icon name="star" slot="icon"></bq-icon>
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
      <div slot="footer">
        <bq-button size="small">Button</bq-button>
        <bq-button appearance="link" size="small">Button</bq-button>
      </div>
    </bq-alert>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup lang="ts">
import { BqAlert, BqButton, BqIcon } from "@beeq/vue";
</script>

<template>
  <BqAlert open>
    <BqIcon name="star" slot="icon" />
    Title
  </BqAlert>

  <BqAlert open>
    <BqIcon name="star" slot="icon" />
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open>
    <BqIcon name="star" slot="icon" />
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</template>
```

> [!WARNING]
>
> Alert fills the width of its parent container.

### Info

Use the `info` variant when users need additional, non-critical information. It works well for context that helps users understand a state without requiring immediate action.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-alert open type="info">Title</bq-alert>
<bq-alert open type="info">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
</bq-alert>

<bq-alert open type="info">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
  <div slot="footer">
    <bq-button size="small">Button</bq-button>
    <bq-button appearance="link" size="small">Button</bq-button>
  </div>
</bq-alert>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { BqAlert, BqButton } from "@beeq/react";

<>
  <BqAlert open type="info">Title</BqAlert>

  <BqAlert open type="info">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="info">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqAlert, BqButton } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqAlert, BqButton],
  template: `
    <bq-alert open type="info">Title</bq-alert>

    <bq-alert open type="info">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
    </bq-alert>

    <bq-alert open type="info">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
      <div slot="footer">
        <bq-button size="small">Button</bq-button>
        <bq-button appearance="link" size="small">Button</bq-button>
      </div>
    </bq-alert>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup lang="ts">
import { BqAlert, BqButton } from "@beeq/vue";
</script>

<template>
  <BqAlert open type="info">Title</BqAlert>

  <BqAlert open type="info">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="info">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</template>
```

### Success

Use the `success` variant to notify users about successful actions or positive outcomes. This type of alert is ideal for celebrating achievements, completed processes, or any operation that concludes successfully.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-alert open type="success">Title</bq-alert>
<bq-alert open type="success">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
</bq-alert>

<bq-alert open type="success">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
  <div slot="footer">
    <bq-button size="small">Button</bq-button>
    <bq-button appearance="link" size="small">Button</bq-button>
  </div>
</bq-alert>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { BqAlert, BqButton } from "@beeq/react";

<>
  <BqAlert open type="success">Title</BqAlert>

  <BqAlert open type="success">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="success">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqAlert, BqButton } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqAlert, BqButton],
  template: `
    <bq-alert open type="success">Title</bq-alert>

    <bq-alert open type="success">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
    </bq-alert>

    <bq-alert open type="success">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
      <div slot="footer">
        <bq-button size="small">Button</bq-button>
        <bq-button appearance="link" size="small">Button</bq-button>
      </div>
    </bq-alert>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup lang="ts">
import { BqAlert, BqButton } from "@beeq/vue";
</script>

<template>
  <BqAlert open type="success">Title</BqAlert>

  <BqAlert open type="success">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="success">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</template>
```

### Warning

Use the `warning` variant to indicate potential issues or actions that users should approach with caution. This alert helps draw attention to situations that require careful consideration but may not be critical.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-alert open type="warning">Title</bq-alert>
<bq-alert open type="warning">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
</bq-alert>

<bq-alert open type="warning">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
  <div slot="footer">
    <bq-button size="small">Button</bq-button>
    <bq-button appearance="link" size="small">Button</bq-button>
  </div>
</bq-alert>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { BqAlert, BqButton } from "@beeq/react";

<>
  <BqAlert open type="warning">Title</BqAlert>

  <BqAlert open type="warning">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="warning">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqAlert, BqButton } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqAlert, BqButton],
  template: `
    <bq-alert open type="warning">Title</bq-alert>

    <bq-alert open type="warning">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
    </bq-alert>

    <bq-alert open type="warning">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
      <div slot="footer">
        <bq-button size="small">Button</bq-button>
        <bq-button appearance="link" size="small">Button</bq-button>
      </div>
    </bq-alert>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup lang="ts">
import { BqAlert, BqButton } from "@beeq/vue";
</script>

<template>
  <BqAlert open type="warning">Title</BqAlert>

  <BqAlert open type="warning">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="warning">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</template>
```

### Error

Use the `error` variant for issues that require immediate attention. It works best for problems that block the task or prevent a successful outcome.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-alert open type="error">Title</bq-alert>
<bq-alert open type="error">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
</bq-alert>

<bq-alert open type="error">
  Title
  <span slot="body">
    Description
    <a class="bq-link" href="https://example.com">Link</a>
  </span>
  <div slot="footer">
    <bq-button size="small">Button</bq-button>
    <bq-button appearance="link" size="small">Button</bq-button>
  </div>
</bq-alert>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { BqAlert, BqButton } from "@beeq/react";

<>
  <BqAlert open type="error">Title</BqAlert>

  <BqAlert open type="error">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="error">
    Title
    <span slot="body">
      Description
      <a className="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqAlert, BqButton } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqAlert, BqButton],
  template: `
    <bq-alert open type="error">Title</bq-alert>

    <bq-alert open type="error">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
    </bq-alert>

    <bq-alert open type="error">
      Title
      <span slot="body">
        Description
        <a class="bq-link" href="https://example.com">Link</a>
      </span>
      <div slot="footer">
        <bq-button size="small">Button</bq-button>
        <bq-button appearance="link" size="small">Button</bq-button>
      </div>
    </bq-alert>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup lang="ts">
import { BqAlert, BqButton } from "@beeq/vue";
</script>

<template>
  <BqAlert open type="error">Title</BqAlert>

  <BqAlert open type="error">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
  </BqAlert>

  <BqAlert open type="error">
    Title
    <span slot="body">
      Description
      <a class="bq-link" href="https://example.com">Link</a>
    </span>
    <div slot="footer">
      <BqButton size="small">Button</BqButton>
      <BqButton appearance="link" size="small">Button</BqButton>
    </div>
  </BqAlert>
</template>
```

## Options

### Sticky

Use the `sticky` attribute for persistent alerts that remain visible until users dismiss them. Sticky alerts work well for ongoing information that needs prolonged attention, such as system updates or maintenance notices.

> [!TIP]
>
> Sticky alerts support every alert type: `default`, `success`, `error`, `warning`, and `info`.

```html HTML icon="html5" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<main>
  <h1>Dashboard</h1>
  <div></div>

  <bq-alert sticky open type="error">
    Title
    <bq-button appearance="link" size="small">Button</bq-button>
  </bq-alert>
</main>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { BqAlert, BqButton } from "@beeq/react";

<main>
  <h1>Dashboard</h1>
  <div></div>

  <BqAlert sticky open type="error">
    Title
    <BqButton appearance="link" size="small">Button</BqButton>
  </BqAlert>
</main>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqAlert, BqButton } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqAlert, BqButton],
  template: `
    <main>
      <h1>Dashboard</h1>
      <div></div>

      <bq-alert sticky open type="error">
        Title
        <bq-button appearance="link" size="small">Button</bq-button>
      </bq-alert>
    </main>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup lang="ts">
import { BqAlert, BqButton } from "@beeq/vue";
</script>

<template>
  <main>
    <h1>Dashboard</h1>
    <div></div>

    <BqAlert sticky open type="error">
      Title
      <BqButton appearance="link" size="small">Button</BqButton>
    </BqAlert>
  </main>
</template>
```

> [!WARNING]
>
> Sticky alerts use a preset layout with the alert text centered at the top of the screen.

### Auto-dismiss

Set `auto-dismiss` to hide the alert automatically after a delay. Use `time` to override the default 3000 ms. Set a minimum of 8000 ms for alerts with meaningful content so users have enough time to read the message.

> [!WARNING]
>
> Do not use `auto-dismiss` for alerts that contain errors, required actions, or legal information.

```html HTML icon="html5" theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-alert open auto-dismiss time="8000" type="success">
  Changes saved
  <span slot="body">Your settings have been updated.</span>
</bq-alert>
```

```jsx React icon="react" theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { BqAlert } from "@beeq/react";

<BqAlert open autoDismiss time={8000} type="success">
  Changes saved
  <span slot="body">Your settings have been updated.</span>
</BqAlert>
```

```ts Angular icon="angular" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { Component } from "@angular/core";
import { BqAlert } from "@beeq/angular/standalone";

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqAlert],
  template: `
    <bq-alert open auto-dismiss time="8000" type="success">
      Changes saved
      <span slot="body">Your settings have been updated.</span>
    </bq-alert>
  `,
})
export class AppComponent {}
```

```vue Vue icon="vuejs" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
<script setup lang="ts">
import { BqAlert } from "@beeq/vue";
</script>

<template>
  <BqAlert open :autoDismiss="true" :time="8000" type="success">
    Changes saved
    <span slot="body">Your settings have been updated.</span>
  </BqAlert>
</template>
```

## Best practices

> [card]
>
> Do
>
> Place alerts close to the content or workflow they affect.

> [card]
>
> Don't
>
> Do not place alerts where they hide controls or interrupt a critical task.

> [card]
>
> Do
>
> Write a short title that explains the state, then add body text only when users need context.

> [card]
>
> Don't
>
> Do not use long paragraphs or unrelated links inside an alert.

> [card]
>
> Do
>
> Give users enough time to read auto-dismiss alerts and keep important messages dismissible by intent.

> [card]
>
> Don't
>
> Do not auto-dismiss alerts that contain errors, required actions, or legal information.

> [card]
>
> Do
>
> Match the alert type, icon, and action style to the severity of the message.

> [card]
>
> Don't
>
> Do not mix severity colors or custom icons in ways that make the alert harder to scan.

## Accessibility

* The host uses `role="alert"` so assistive technologies announce the message when it appears.
* The host sets `aria-hidden` from the `open` state, keeping hidden alerts out of the accessibility tree.
* The default close button has the accessible label "Close alert."
* `type` provides visual intent and a matching predefined status icon for `info`, `success`, `warning`, and `error`.
* Alerts should have a concise title in the default slot and put supporting details in the `body` slot when users need more context.
* The built-in type tokens (`info`, `success`, `warning`, `error`) meet WCAG AA color-contrast requirements in both light and dark themes. You must verify contrast manually when using custom colors via CSS variables.
* All interactive elements inside the alert (the close button, footer actions, and body links) must be reachable via `Tab` and must have a visible focus indicator.
* You should set `time` to at least 8000 ms for `auto-dismiss` alerts, and should not auto-dismiss while the user has keyboard focus or hover inside the alert.
* When `sticky` is enabled, you must keep the page focus order logical so keyboard users can still reach the affected content.

### Keyboard interaction

The alert itself is not focusable. Only the elements inside it receive focus; the close button is a native `<button>` rendered by `bq-button`.

| Key | Context | Action |
| - | - | - |
| `Tab` | Alert open, close button shown | Moves focus to the close button, then to focusable content in the `body` and `footer` slots |
| `Shift` + `Tab` | Focus inside the alert | Moves focus to the previous focusable element |
| `Enter` | Close button focused | Activates the button and hides the alert |
| `Space` | Close button focused | Activates the button and hides the alert |

### Rules

| Rule | Strength | Verified by |
| - | - | - |
| Keep every interactive element inside the alert (close button, footer actions, body links) reachable with `Tab` and visibly focused | MUST | manual: tab through links and actions and inspect the focus indicator |
| Verify color contrast manually when you override colors with CSS variables | MUST | manual: measure contrast after overriding alert colors |
| Keep the page focus order logical when `sticky` is set | MUST | manual: tab through the page with the alert sticky |
| Put a concise title in the default slot and details in the `body` slot | SHOULD | manual: read the title and body slots in order |
| Set `time` to at least 8000 ms for `auto-dismiss` | SHOULD | manual: check the auto-dismiss time in the example |
| Do not auto-dismiss while the user has focus or hover inside the alert | SHOULD NOT | manual: focus and hover over the alert until dismissal would occur |

## API reference

### Properties

| Property | Attribute | Description | Type | Default |
| - | - | - | - | - |
| `autoDismiss` | `auto-dismiss` | If `true`, the alert will automatically hide after the specified amount of time | `boolean` | `false` |
| `border` | `border` | The corner radius of the alert component | `'none'` \| `'xs2'` \| `'xs'` \| `'s'` \| `'m'` \| `'l'` \| `'full'` | `'s'` |
| `disableClose` | `disable-close` | If `true`, the close button at the top right of the alert will not be shown | `boolean` | `false` |
| `hideIcon` | `hide-icon` | If `true`, the alert icon will not be shown | `boolean` | `false` |
| `open` | `open` | If `true`, the alert will be shown | `boolean` | `false` |
| `sticky` | `sticky` | If `true`, the alert remains fixed at the top of the page, occupying the full viewport width | `boolean` | `false` |
| `time` | `time` | The length of time, in milliseconds, after which the alert closes itself. Only valid when `auto-dismiss` is set | `number` | `3000` |
| `type` | `type` | Type of alert | `'default'` \| `'error'` \| `'info'` \| `'success'` \| `'warning'` | `'default'` |

### Invalid combinations

| Combination | Strength | Result |
| - | - | - |
| `time` without `auto-dismiss` | SHOULD NOT | `time` is ignored and the alert never closes itself |

### Events

| Event | Description | Type |
| - | - | - |
| `bqHide` | Fires when the alert starts to hide | `CustomEvent<any>` |
| `bqShow` | Fires when the alert starts to show | `CustomEvent<any>` |
| `bqAfterHide` | Fires after the alert has been hidden | `CustomEvent<any>` |
| `bqAfterShow` | Fires after the alert has been shown | `CustomEvent<any>` |

> [!NOTE]
>
> * In React, prefix events with `on`: `onBqShow`, `onBqHide`, `onBqAfterShow`, `onBqAfterHide`.
> * In Angular, use the event binding syntax: `(bqShow)`, `(bqHide)`, `(bqAfterShow)`, `(bqAfterHide)`.
> * In Vue, use the `@` shorthand: `@bqShow`, `@bqHide`, `@bqAfterShow`, `@bqAfterHide`.

### Methods

| Method | Description | Type |
| - | - | - |
| `show()` | Shows the alert component | `Promise<void>` |
| `hide()` | Hides the alert component | `Promise<void>` |

### Slots

| Slot | Description |
| - | - |
| *(default)* | The alert title content |
| `body` | The alert description content |
| `footer` | The alert footer content |
| `icon` | Custom icon content. Status types render predefined icons when this slot is empty |
| `btn-close` | Custom close button content |

### Shadow parts

| Part | Description |
| - | - |
| `base` | The `<div>` container of the predefined `bq-icon` component |
| `body` | The container `<div>` that wraps the alert description content |
| `btn-close` | The native button of the `bq-button` used to close the alert |
| `content` | The container `<div>` that wraps all alert content: title, description, and footer |
| `footer` | The container `<div>` that wraps the alert footer content |
| `icon` | The `<bq-icon>` element used to render a predefined icon based on the alert type |
| `icon-outline` | The container `<div>` that wraps the icon element |
| `main` | The container `<div>` that wraps the alert main content |
| `svg` | The `<svg>` element of the predefined `bq-icon` component |
| `title` | The container `<div>` that wraps the alert title content |
| `wrapper` | The wrapper container `<div>` inside the shadow DOM |

### CSS custom properties

**CSS variables**

| Variable | Description | Default |
| - | - | - |
| `--bq-alert--background` | Alert background color | `var(--bq-ui--secondary)` |
| `--bq-alert--border-radius` | Alert border radius | `var(--bq-radius--s)` |
| `--bq-alert--content-footer-gap` | Gap between content and footer | `var(--bq-spacing-s)` |
| `--bq-alert--title-body-gap` | Gap between title and body | `var(--bq-spacing-s)` |
| `--bq-alert--background-info` | Background color for info alerts | `var(--bq-ui--info-alt)` |
| `--bq-alert--background-success` | Background color for success alerts | `var(--bq-ui--success-alt)` |
| `--bq-alert--background-warning` | Background color for warning alerts | `var(--bq-ui--warning-alt)` |
| `--bq-alert--background-error` | Background color for error alerts | `var(--bq-ui--danger-alt)` |
| `--bq-alert--background-default` | Background color for default alerts | `var(--bq-ui--primary)` |
| `--bq-alert--border-info` | Border color for info alerts | `var(--bq-stroke--info)` |
| `--bq-alert--border-success` | Border color for success alerts | `var(--bq-stroke--success)` |
| `--bq-alert--border-warning` | Border color for warning alerts | `var(--bq-stroke--warning)` |
| `--bq-alert--border-error` | Border color for error alerts | `var(--bq-stroke--danger)` |
| `--bq-alert--border-default` | Border color for default alerts | `var(--bq-stroke--secondary)` |
| `--bq-alert--border-width` | Alert border width | `var(--bq-stroke-s)` |
| `--bq-alert--border-style` | Alert border style | `solid` |
| `--bq-alert--icon-color-info` | Icon color for info alerts | `var(--bq-icon--info)` |
| `--bq-alert--icon-color-success` | Icon color for success alerts | `var(--bq-icon--success)` |
| `--bq-alert--icon-color-warning` | Icon color for warning alerts | `var(--bq-icon--warning)` |
| `--bq-alert--icon-color-error` | Icon color for error alerts | `var(--bq-icon--danger)` |
| `--bq-alert--icon-color-default` | Icon color for default alerts | `var(--bq-icon--primary)` |
| `--bq-alert--text-color` | Alert text color | `var(--bq-text--primary)` |
| `--bq-alert--padding` | Alert padding | `var(--bq-spacing-s)` |
| `--bq-alert--min-width` | Alert minimum width | `320px` |
| `--bq-alert--z-index` | Stacking order of a sticky alert | No declared default |

> [!NOTE]
>
> Set `--bq-alert--z-index` on the alert when your page needs an explicit stacking order. Without an override, the sticky alert's `z-index` computes to `auto`. Use the type-specific `--bq-alert--border-*` variables to customize its border color.

> [!TIP]
>
> Learn more about [styling with shadow parts](https://www.beeq.design/guides/styles.md#component-shadow-dom-parts) and [CSS custom properties](https://www.beeq.design/guides/styles.md#global-css-custom-properties).

## Resources

Use Storybook to test behavior and states interactively, or review the source if you need implementation details.

> [card] [Interactive playground](https://storybook.beeq.design/?path=/story/components-alert--default)
>
> Explore all alert configurations in Storybook

> [card] [Source code](https://github.com/Endava/BEEQ/tree/main/packages/beeq/src/components/alert)
>
> View the component source on GitHub


## Related topics

- [Status](https://www.beeq.design/components/status.md)
- [Custom Theme](https://www.beeq.design/theming/custom-theme.md)
- [Changelog](https://www.beeq.design/releases/changelog.md)
- [Notification](https://www.beeq.design/components/notification.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.