v2.15.0

Alert

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

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

Заголовок

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

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

Описание

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

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

Иконка

Пропс icon показывает иконку.

Внимание!
Мы сразу сообщим менеджеру, что сделка не продвигается.
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

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

Аватар

Пропс avatar показывает аватар.

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

Цвет

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

Внимание!
Мы сразу сообщим менеджеру, что сделка не продвигается.
<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.

Доступно только для цветов air-primary*.
Внимание!
Мы сразу сообщим менеджеру, что сделка не продвигается.
<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.

Внимание!
Мы сразу сообщим менеджеру, что сделка не продвигается.
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

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

Закрытие

Пропс close показывает кнопку, которой закрывают Alert.

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

Для настройки кнопки передайте любое свойство компонента Button.

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

Действия

Пропс actions добавляет в Alert действия — кнопки.

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

Ориентация

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

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

API

Пропсы

Prop Default Type
as'div'any

The element or component this component should render as.

title string
description string
iconIconComponent

Display an icon on the left side.

avatar AvatarProps
color'air-secondary-accent'"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"
invertedfalseboolean

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.

orientation'vertical' "vertical" | "horizontal"

The orientation between the content and the actions.

size'md' "md" | "sm"
actions ButtonProps[]

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' }
closefalseboolean | Omit<ButtonProps, LinkPropsKeys>

Display a close button to dismiss the alert. { size: 'md', color: 'air-tertiary-no-accent' }

closeIconicons.closeIconComponent

The icon displayed in the close button.

b24ui { root?: SlotClass; wrapper?: SlotClass; title?: SlotClass; description?: SlotClass; icon?: SlotClass; avatar?: SlotClass; avatarSize?: SlotClass; actions?: SlotClass; close?: SlotClass; }

Слоты

Slot Type
leading{ b24ui: object; }
title{}
description{}
actions{}
close{ b24ui: object; }

События

Event Type
update:open[value: boolean]

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/alert.ts
export default {
  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'
      }
    }
  ],
  defaultVariants: {
    color: 'air-secondary-accent',
    size: 'md',
    inverted: false
  }
}
Some colors in compoundVariants are omitted for readability. Check out the source code on GitHub.