---
title: "Alert"
description: "Оповещение, которое привлекает внимание пользователя."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/alert"
---
# Alert

> Оповещение, которое привлекает внимание пользователя.

## Использование

### Заголовок

Пропс `title` задаёт заголовок Alert.

```vue
<template>
  <B24Alert title="Внимание!" />
</template>
```

### Описание

Пропс `description` задаёт описание Alert.

```vue
<template>
  <B24Alert title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." />
</template>
```

### Иконка

Пропс `icon` показывает [иконку](https://bitrix24.github.io/b24icons/icons/).

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Alert :icon="RocketIcon" title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." />
</template>
```

### Аватар

Пропс `avatar` показывает [аватар](https://b24-ui.bx-shef.by/raw/docs/components/avatar.md).

```vue
<template>
  <B24Alert :avatar="{src:'/b24ui/avatar/employee.png',size:'xs',loading:'lazy'}" title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." />
</template>
```

### Цвет

Пропс `color` меняет цвет Alert.

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Alert color="air-primary" title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." :icon="RocketIcon" close />
</template>
```

### Инверсия

Пропс `inverted` инвертирует цвет Alert.

> [!WARNING]
> Доступно только для цветов `air-primary*`.

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Alert inverted color="air-primary" title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." :icon="RocketIcon" close />
</template>
```

### Размер

Пропс `size` меняет размер Alert.

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Alert size="md" title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." :icon="RocketIcon" />
</template>
```

### Закрытие

Пропс `close` показывает [кнопку](https://b24-ui.bx-shef.by/raw/docs/components/button.md), которой закрывают Alert.

> [!TIP]
> По нажатию на кнопку закрытия возникает событие `update:open`.

```vue
<template>
  <B24Alert close title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." />
</template>
```

Для настройки кнопки передайте любое свойство компонента [Button](https://b24-ui.bx-shef.by/raw/docs/components/button.md).

```vue
<template>
  <B24Alert title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." :close="{color:'air-secondary-accent-2',class:'rounded-full'}" />
</template>
```

### Действия

Пропс `actions` добавляет в Alert действия — [кнопки](https://b24-ui.bx-shef.by/raw/docs/components/button.md).

```vue
<template>
  <B24Alert title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." :actions="{'0':{label:'Действие 1'},'1':{label:'Действие 2',color:'air-primary'}}" />
</template>
```

### Ориентация

Пропс `orientation` меняет ориентацию Alert.

```vue
<template>
  <B24Alert title="Внимание!" description="Мы сразу сообщим менеджеру, что сделка не продвигается." orientation="horizontal" :actions="{'0':{label:'Действие 1'},'1':{label:'Действие 2',color:'air-primary'}}" />
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the Alert component
 */
interface AlertProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  title?: string | undefined;
  description?: string | undefined;
  /**
   * Display an icon on the left side.
   */
  icon?: (props: HTMLAttributes & VNodeProps & {}, ctx: Omit<{ attrs: Attrs; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<...>>(exposed?: Exposed | undefined) => void; }, "expose">): any | undefined;
  avatar?: AvatarProps | undefined;
  /**
   * @default 'air-secondary-accent'
   */
  color?: "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary" | "air-secondary-alert" | "air-secondary-accent" | "air-secondary-accent-1" | "air-secondary-accent-2" | "air-tertiary";
  /**
   * If set to `true` the color is inverted.
   * Used for 'air-primary', 'air-primary-success', 'air-primary-alert', 'air-primary-copilot' and 'air-primary-warning' colors.
   * @default false
   */
  inverted?: boolean | undefined;
  /**
   * The orientation between the content and the actions.
   * @default 'vertical'
   */
  orientation?: "vertical" | "horizontal" | undefined;
  /**
   * @default 'md'
   */
  size?: "md" | "sm" | undefined;
  /**
   * Display a list of actions:
   * - under the title and description when orientation is `vertical`
   * - next to the close button when orientation is `horizontal`
   * `{ size: 'sm' }`{lang="ts"}
   */
  actions?: ButtonProps[] | undefined;
  /**
   * Display a close button to dismiss the alert.
   * `{ size: 'md', color: 'air-tertiary-no-accent' }`{lang="ts"}
   * @default false
   */
  close?: boolean | Omit<ButtonProps, LinkPropsKeys> | undefined;
  /**
   * The icon displayed in the close button.
   * @default icons.close
   */
  closeIcon?: (props: HTMLAttributes & VNodeProps & {}, ctx: Omit<{ attrs: Attrs; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<...>>(exposed?: Exposed | undefined) => void; }, "expose">): any | undefined;
  b24ui?: { root?: SlotClass; wrapper?: SlotClass; title?: SlotClass; description?: SlotClass; icon?: SlotClass; avatar?: SlotClass; avatarSize?: SlotClass; actions?: SlotClass; close?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the Alert component
 */
interface AlertSlots {
  leading(): any;
  title(): any;
  description(): any;
  actions(): any;
  close(): any;
}
```

### События

```ts
/**
 * Emitted events for the Alert component
 */
interface AlertEmits {
  update:open: (payload: [value: boolean]) => void;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    alert: {
      slots: {
        root: 'relative overflow-hidden w-full flex text-(--b24ui-color) bg-(--b24ui-background) border-(--b24ui-border-color) border-(length:--b24ui-border-width) rounded-(--ui-border-radius-md)',
        wrapper: 'min-w-0 flex-1 flex flex-col font-[family-name:var(--ui-font-family-primary)]',
        title: 'font-(--ui-font-weight-bold)',
        description: '',
        icon: 'shrink-0 size-6',
        avatar: 'shrink-0',
        avatarSize: '',
        actions: 'flex flex-wrap gap-1.5 shrink-0',
        close: 'p-0 [--ui-btn-color:var(--b24ui-color)] hover:bg-(--ui-color-base-white-fixed)/10 focus-visible:bg-(--ui-color-base-white-fixed)/10 -me-1.5 lg:me-0'
      },
      variants: {
        color: {
          'air-primary': {
            root: 'style-filled'
          },
          'air-primary-success': {
            root: 'style-filled-success'
          },
          'air-primary-alert': {
            root: 'style-filled-alert'
          },
          'air-primary-copilot': {
            root: 'style-filled-copilot'
          },
          'air-primary-warning': {
            root: 'style-filled-warning'
          },
          'air-secondary': {
            root: 'style-tinted'
          },
          'air-secondary-alert': {
            root: 'style-tinted-alert'
          },
          'air-secondary-accent': {
            root: 'style-outline'
          },
          'air-secondary-accent-1': {
            root: 'style-outline-accent-1'
          },
          'air-secondary-accent-2': {
            root: 'style-outline-accent-2'
          },
          'air-tertiary': {
            root: 'style-outline-no-accent'
          },
          default: {
            root: 'style-old-default'
          },
          danger: {
            root: 'style-old-danger'
          },
          success: {
            root: 'style-old-success'
          },
          warning: {
            root: 'style-old-warning'
          },
          primary: {
            root: 'style-old-primary'
          },
          secondary: {
            root: 'style-old-secondary'
          },
          collab: {
            root: 'style-old-collab'
          },
          ai: {
            root: 'style-old-ai'
          }
        },
        size: {
          sm: {
            root: 'py-xs ps-sm pe-xs gap-2',
            title: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-lg)',
            description: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-lg)',
            avatarSize: 'md'
          },
          md: {
            root: 'py-md ps-md pe-xs gap-2.5',
            title: 'text-(length:--ui-font-size-md)/(--ui-font-line-height-reset)',
            description: 'text-(length:--ui-font-size-md)/(--ui-font-line-height-3xs)',
            avatarSize: 'xl'
          }
        },
        orientation: {
          horizontal: {
            root: 'items-center',
            actions: 'items-center'
          },
          vertical: {
            root: 'items-start',
            actions: 'items-start mt-2'
          }
        },
        title: {
          true: {
            description: 'mt-1'
          }
        },
        inverted: {
          true: '',
          false: ''
        }
      },
      compoundVariants: [
        {
          inverted: true,
          color: 'air-primary',
          class: {
            root: 'style-filled-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-success',
          class: {
            root: 'style-filled-success-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-alert',
          class: {
            root: 'style-filled-alert-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-copilot',
          class: {
            root: 'style-filled-copilot-inverted'
          }
        },
        {
          inverted: true,
          color: 'air-primary-warning',
          class: {
            root: 'style-filled-warning-inverted'
          }
        }
      ],
      defaultVariants: {
        color: 'air-secondary-accent',
        size: 'md',
        inverted: false
      }
    }
  }
})
```

## Sitemap

See the full [sitemap](/sitemap.md) for all pages.
