> ## 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.

# Toast

> Toasts provide short, time-based feedback about an action or system state without interrupting the current task.

![BEEQ Toast component overview](https://mintcdn.com/beeq/Z4ffKipt5yZIDQUT/components/images/toast/toast-overview-light.svg?fit=max\&auto=format\&n=Z4ffKipt5yZIDQUT\&q=85\&s=cc64b95a806188811729d36352ea2e7a)

Toast component overview

Toasts are brief, non-blocking status messages that appear temporarily to confirm an action, report a lightweight issue, or indicate background progress. They keep people informed without pulling them out of their current flow.

> [!NOTE]
>
> You should use a toast for lightweight feedback that does not require a response. If the message is longer, needs actions, or must remain visible until dismissed, you should use a [notification](https://www.beeq.design/components/notification.md) or [dialog](https://www.beeq.design/components/dialog.md) instead.

## When to use

> [card]
>
> Use toasts when
>
> * Confirming that a user-triggered action completed successfully
> * Reporting a lightweight issue that does not block the current task
> * Indicating short-lived background activity such as syncing or loading
> * Keeping feedback close to the moment of interaction without interrupting the page

> [card]
>
> Do not use toasts when
>
> * The message is critical and must not be missed
> * The user needs to choose an action before continuing
> * The content is too long to scan in a few seconds
> * Multiple concurrent messages would compete for attention

> [!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

> [card] Informational toast
>
> Informational toasts provide users with relevant information or guidance about a particular action or feature.

> [card] Error toast
>
> Error toasts inform the user about issues that occur during user interaction and provide guidance on how to resolve them.

> [card] Loading toast
>
> Loading toasts indicate to users that a process is underway, such as data retrieval or content loading.

> [card] Success toast
>
> Success toasts confirm to users that an action has been completed successfully.

> [card] Warning toast
>
> Warning toasts warn users about potential risks or issues that require attention.

> [card] Custom toast
>
> Custom toasts are personalized messages tailored to specific user interactions or application contexts.

## Anatomy

![BEEQ Toast component anatomy](https://mintcdn.com/beeq/Z4ffKipt5yZIDQUT/components/images/toast/toast-anatomy-light.svg?fit=max\&auto=format\&n=Z4ffKipt5yZIDQUT\&q=85\&s=e1e6a0eee65e9ce7576273239da54a2d)

Toast component anatomy

Each toast contains a compact message and, by default, a semantic icon that helps users understand the status instantly. Toasts should always include a clear label, and that label should be paired with the icon that best matches the message meaning.

| Part | Element | Description |
| - | - | - |
| **1** | Container | The surface that groups the feedback message into one compact unit |
| **2** | Icon | A semantic icon that reinforces the toast type at a glance |
| **3** | Label | The short message describing what happened or what is happening |

> [!NOTE]
>
> Toasts use a standard size intended to work across most interfaces. Prefer the default sizing and spacing so messages stay compact, readable, and visually consistent.

## Design guidelines

Use toast messages carefully so they stay brief, noticeable, and easy to understand without interrupting the current task.

**1. Be concise**

Keep the message short and direct. Limit the content to one or two brief sentences.

**2. Provide context**

Include enough context for users to understand why the toast appeared and what happened.

**3. Use sentence case**

Write toast text in sentence case instead of using capitalization to force emphasis.

> [!NOTE]
>
> You should show one toast at a time when possible. If several events happen close together, you should use a controlled queue or a tightly managed stack so messages remain readable and do not overlap bottom navigation, floating action buttons, or other critical controls.

## Usage

### Default

Use the built-in `type` values to communicate the nature of the message quickly. Keep the text concise and let the icon and color carry the status cue. `info` is the default type, while `success`, `alert`, `error`, and `loading` cover the most common toast states.

```html HTML icon="html5" theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-toast open>This is an informational message.</bq-toast>
<bq-toast open type="success">Your profile was updated.</bq-toast>
<bq-toast open type="alert">Your session will expire soon.</bq-toast>
<bq-toast open type="error">We couldn't complete the request.</bq-toast>
<bq-toast open type="loading">Uploading file...</bq-toast>
```

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

<>
  <BqToast open>This is an informational message.</BqToast>
  <BqToast open type="success">Your profile was updated.</BqToast>
  <BqToast open type="alert">Your session will expire soon.</BqToast>
  <BqToast open type="error">We couldn't complete the request.</BqToast>
  <BqToast open type="loading">Uploading file...</BqToast>
</>
```

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

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqToast],
  template: `
    <bq-toast open>This is an informational message.</bq-toast>
    <bq-toast open type="success">Your profile was updated.</bq-toast>
    <bq-toast open type="alert">Your session will expire soon.</bq-toast>
    <bq-toast open type="error">We couldn't complete the request.</bq-toast>
    <bq-toast open type="loading">Uploading file...</bq-toast>
  `
})
export class AppComponent {}
```

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

<template>
  <BqToast open>This is an informational message.</BqToast>
  <BqToast open type="success">Your profile was updated.</BqToast>
  <BqToast open type="alert">Your session will expire soon.</BqToast>
  <BqToast open type="error">We couldn't complete the request.</BqToast>
  <BqToast open type="loading">Uploading file...</BqToast>
</template>
```

## Options

**Allowed `type` values:** `info` (default), `success`, `alert`, `error`, `loading`, `custom`. Use `custom` with the `icon` slot for your own icon.

**Allowed `placement` values:** `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center` (default), `bottom-right`. Placement applies to the fixed-position portal created by `toast()`.

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

### Custom icon

Use `type="custom"` when you need a branded or domain-specific status cue. Replace the default icon through the `icon` slot.

```html HTML icon="html5" theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-toast open type="custom">
  <bq-icon slot="icon" name="star-bold"></bq-icon>
  New feature added to your workspace.
</bq-toast>
```

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

<BqToast open type="custom">
  <BqIcon slot="icon" name="star-bold" />
  New feature added to your workspace.
</BqToast>
```

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

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqIcon, BqToast],
  template: `
    <bq-toast open type="custom">
      <bq-icon slot="icon" name="star-bold"></bq-icon>
      New feature added to your workspace.
    </bq-toast>
  `
})
export class AppComponent {}
```

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

<template>
  <BqToast open type="custom">
    <BqIcon slot="icon" name="star-bold" />
    New feature added to your workspace.
  </BqToast>
</template>
```

### Portal placement and stacking

Use a dedicated toast container when you want the stacking behavior to be explicit in the markup. This example keeps the stack at the top center and appends each new toast into the same container, while keeping the visible documentation focused on the structure rather than the implementation details.

```js JavaScript icon="js" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
const TOAST_TYPE = ['info', 'success', 'alert', 'error', 'loading'];

const button = previewRoot.querySelector('bq-button');
const toastContainer = previewRoot.querySelector('[data-toast-container]');

const getRandomType = () => TOAST_TYPE[Math.floor(Math.random() * TOAST_TYPE.length)];
const createToast = (type, message) => {
  const toast = document.createElement('bq-toast');
  toast.setAttribute('type', type);
  toast.setAttribute('time', '4000');
  toast.textContent = message;
  return toast;
};

button.addEventListener('bqClick', async () => {
  await customElements.whenDefined('bq-toast');

  const type = getRandomType();
  const toast = createToast(type, 'This is a message');

  toastContainer.appendChild(toast);
  toast.open = true;

  window.setTimeout(() => {
    toast.open = false;
    window.setTimeout(() => {
      toast.remove();
    }, 300);
  }, 4000);
});
```

```html HTML icon="html5" theme={"theme":{"light":"one-light","dark":"night-owl"}}
<bq-button>Toggle toast</bq-button>

<div data-toast-container></div>
```

```jsx React icon="react" expandable theme={"theme":{"light":"one-light","dark":"night-owl"}}
import { useEffect, useRef, useState } from "react";
import { createPortal } from "react-dom";
import { BqButton, BqToast } from "@beeq/react";

const TOAST_TYPES = ['info', 'success', 'alert', 'error', 'loading'];

export function ToastStackExample() {
  const [toasts, setToasts] = useState([]);
  const timerIds = useRef(new Set());

  useEffect(() => () => timerIds.current.forEach(clearTimeout), []);

  const handleClick = () => {
    const id = Date.now();
    const type = TOAST_TYPES[Math.floor(Math.random() * TOAST_TYPES.length)];
    setToasts((prev) => [...prev, { id, type }]);

    const timer = window.setTimeout(() => {
      setToasts((prev) => prev.filter((t) => t.id !== id));
      timerIds.current.delete(timer);
    }, 4000);
    timerIds.current.add(timer);
  };

  return (
    <>
      <BqButton onBqClick={handleClick}>Toggle toast</BqButton>
      {createPortal(
        <div data-toast-container>
          {toasts.map(({ id, type }) => (
            <BqToast key={id} open type={type} time={4000}>
              This is a message
            </BqToast>
          ))}
        </div>,
        document.body
      )}
    </>
  );
}
```

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

interface ToastItem { id: number; type: string; }

const TOAST_TYPES = ['info', 'success', 'alert', 'error', 'loading'];

@Component({
  selector: "app-root",
  standalone: true,
  imports: [BqButton, BqToast],
  template: `
    <bq-button (bqClick)="handleClick()">Toggle toast</bq-button>
    <div data-toast-container>
      @for (toast of toasts; track toast.id) {
        <bq-toast open [attr.type]="toast.type" time="4000">
          This is a message
        </bq-toast>
      }
    </div>
  `,
})
export class AppComponent {
  toasts: ToastItem[] = [];
  private readonly timerIds = new Set<ReturnType<typeof setTimeout>>();
  private readonly destroyRef = inject(DestroyRef);

  constructor() {
    this.destroyRef.onDestroy(() => this.timerIds.forEach(clearTimeout));
  }

  handleClick() {
    const id = Date.now();
    const type = TOAST_TYPES[Math.floor(Math.random() * TOAST_TYPES.length)];
    this.toasts = [...this.toasts, { id, type }];

    const timer = window.setTimeout(() => {
      this.toasts = this.toasts.filter((t) => t.id !== id);
      this.timerIds.delete(timer);
    }, 4000);
    this.timerIds.add(timer);
  }
}
```

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

interface ToastItem { id: number; type: string; }

const TOAST_TYPES = ['info', 'success', 'alert', 'error', 'loading'];
const toasts = ref<ToastItem[]>([]);
const timerIds = new Set<ReturnType<typeof setTimeout>>();

onUnmounted(() => timerIds.forEach(clearTimeout));

function handleClick() {
  const id = Date.now();
  const type = TOAST_TYPES[Math.floor(Math.random() * TOAST_TYPES.length)];
  toasts.value.push({ id, type });

  const timer = window.setTimeout(() => {
    toasts.value = toasts.value.filter((t) => t.id !== id);
    timerIds.delete(timer);
  }, 4000);
  timerIds.add(timer);
}
</script>

<template>
  <BqButton @bqClick="handleClick">Toggle toast</BqButton>
  <div data-toast-container>
    <BqToast v-for="toast in toasts" :key="toast.id" open :type="toast.type" :time="4000">
      This is a message
    </BqToast>
  </div>
</template>
```

## Best practices

> [card]
>
> Do
>
> Keep toast copy short, direct, and written in sentence case.

> [card]
>
> Don't
>
> Don't use a toast for long explanations, multi-step guidance, or anything users may need to revisit later.

> [card]
>
> Do
>
> Use the correct semantic `type` so icon and color reinforce the meaning immediately.

> [card]
>
> Don't
>
> Don't flood the interface with many simultaneous toasts. If several events occur, queue or stack them in a controlled order.

> [card]
>
> Do
>
> Place viewport toasts where they do not cover bottom navigation, floating actions, or other critical controls.

> [card]
>
> Don't
>
> Don't rely on a toast alone for critical errors or irreversible outcomes that require acknowledgment.

> [card]
>
> Do
>
> Set a long enough `time` for users who may need more seconds to read the message, especially if it contains an error explanation.

> [card]
>
> Don't
>
> Do not auto-dismiss a toast that users may need to act on or reference. Use a notification or dialog for persistent messages instead.

## Accessibility

* **Announced as status** - the component uses `role="status"`, so the message should make sense when read aloud without surrounding visual context.
* **Not color-only** - you must not rely on icon color alone to communicate meaning. The message text itself must state what happened clearly.
* **Allow enough reading time** - you should increase `time` for longer messages, and should not auto-dismiss content people may need more than a few seconds to read.
* **Do not steal focus** - toasts are non-modal status messages, so they must not interrupt the current keyboard focus or workflow.
* **Use a stronger pattern when needed** - if the message requires action, contains links, or must remain available, you must use a persistent notification or dialog instead.

### Keyboard interaction

No keyboard interaction: the component is not focusable.

### Rules

| Rule | Strength | Verified by |
| - | - | - |
| Do not rely on icon color alone; the message text states what happened | MUST NOT | manual: read the message with its icon and color hidden |
| Do not interrupt the current keyboard focus or workflow | MUST NOT | manual: inspect focus before and after the toast appears |
| Use a persistent notification or dialog when the message requires action, contains links, or must stay available | MUST | manual: review actionable messages for a persistent destination |
| Write messages that make sense when read aloud without visual context | SHOULD | manual: read the message aloud without the surrounding screen |
| Increase `time` for longer messages | SHOULD | manual: time dismissal against the message length |

## API reference

### Properties

| Property | Attribute | Description | Type | Default |
| - | - | - | - | - |
| `border` | `border` | Border radius of the toast component | `"none" \| "xs2" \| "xs" \| "s" \| "m" \| "l" \| "full"` | `"s"` |
| `hideIcon` | `hide-icon` | If `true`, the semantic icon is hidden | `boolean` | `false` |
| `open` | `open` | If `true`, the toast is visible | `boolean` | `undefined` |
| `placement` | `placement` | Placement used by the fixed-position toast portal | `"top-left" \| "top-center" \| "top-right" \| "bottom-left" \| "bottom-center" \| "bottom-right"` | `"bottom-center"` |
| `time` | `time` | Duration in milliseconds before the toast closes itself | `number` | `3000` |
| `type` | `type` | Semantic type of the toast | `"info" \| "success" \| "alert" \| "error" \| "loading" \| "custom"` | `"info"` |

### Invalid combinations

No invalid prop combinations.

### Events

| Event | Description | Type |
| - | - | - |
| `bqHide` | Fired when the toast is about to hide | `CustomEvent<HTMLBqToastElement>` |
| `bqShow` | Fired when the toast is about to show | `CustomEvent<HTMLBqToastElement>` |

> [!NOTE]
>
> * In React, prefix events with `on`: `onBqHide`, `onBqShow`.
> * In Angular, use the event binding syntax: `(bqHide)`, `(bqShow)`.
> * In Vue, use the `@` shorthand: `@bqHide`, `@bqShow`.
> * **`preventDefault()` is supported** on both events. Calling it cancels the default show or hide behavior while still letting your event handler run.

### Methods

| Method | Description | Signature |
| - | - | - |
| `show()` | Shows the toast programmatically | `show() => Promise<void>` |
| `hide()` | Hides the toast programmatically | `hide() => Promise<void>` |
| `toast()` | Renders the toast in the fixed-position stacking portal | `toast() => Promise<void>` |

### Slots

| Slot | Description |
| - | - |
| *(default)* | The toast message content |
| `icon` | Replaces the default icon with a custom `bq-icon` |

### Shadow parts

| Part | Description |
| - | - |
| `wrapper` | The internal wrapper that contains the icon and message |
| `icon-info` | The `<div>` container that holds the icon component |
| `base` | The root element of the internal default `bq-icon` |
| `svg` | The `<svg>` element of the internal default `bq-icon` |

### CSS custom properties

**CSS variables**

| Variable | Description | Default |
| - | - | - |
| `--bq-toast--background` | Toast background color | `var(--bq-ui--primary)` |
| `--bq-toast--box-shadow` | Toast shadow | `var(--bq-box-shadow--l)` |
| `--bq-toast--padding-y` | Vertical padding | `var(--bq-spacing-s)` |
| `--bq-toast--padding-x` | Horizontal padding | `var(--bq-spacing-m)` |
| `--bq-toast--gap` | Gap between icon and text | `var(--bq-spacing-xs)` |
| `--bq-toast--border-radius` | Border radius | `var(--bq-radius--s)` |
| `--bq-toast--border-width` | Border width | `unset` |
| `--bq-toast--border-style` | Border style | `none` |
| `--bq-toast--border-color` | Border color | `transparent` |
| `--bq-toast--icon-color-info` | Icon color for `info` toasts | `var(--bq-icon--info)` |
| `--bq-toast--icon-color-success` | Icon color for `success` toasts | `var(--bq-icon--success)` |
| `--bq-toast--icon-color-alert` | Icon color for `alert` toasts | `var(--bq-icon--warning)` |
| `--bq-toast--icon-color-error` | Icon color for `error` toasts | `var(--bq-icon--danger)` |
| `--bq-toast--icon-color-loading` | Icon color for `loading` toasts | `var(--bq-icon--brand)` |
| `--bq-toast--icon-color-custom` | Icon color for `custom` toasts | `var(--bq-icon--primary)` |

> [!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

> [card] [Interactive playground](https://storybook.beeq.design/?path=/story/components-toast--default)
>
> Explore toast types, placement, and stacking behavior in Storybook.

> [card] [Source code](https://github.com/Endava/BEEQ/tree/main/packages/beeq/src/components/toast)
>
> Browse the component implementation, styles, and tests on GitHub.


## Related topics

- [Changelog](https://www.beeq.design/releases/changelog.md)
- [Shadows](https://www.beeq.design/foundations/shadows.md)
- [Notification](https://www.beeq.design/components/notification.md)
- [Alert](https://www.beeq.design/components/alert.md)


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