---
title: "Empty"
description: "Компонент пустого состояния."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/empty"
---
# Empty

> Компонент пустого состояния.

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

```vue [EmptyExample.vue]
<script setup lang="ts">
import ProductIcon from '@bitrix24/b24icons-vue/outline/ProductIcon'
import AddProductIcon from '@bitrix24/b24icons-vue/outline/AddProductIcon'
import RefreshIcon from '@bitrix24/b24icons-vue/outline/RefreshIcon'
</script>

<template>
  <B24Empty
    :icon="ProductIcon"
    title="Проекты не найдены"
    description="Похоже, вы ещё не добавили ни одного проекта. Создайте первый, чтобы начать."
    :actions="[
      {
        label: 'Создать',
        icon: AddProductIcon,
        color: 'air-primary'
      },
      {
        label: 'Обновить',
        icon: RefreshIcon
      }
    ]"
  />
</template>
```

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

Пропс `title` задаёт заголовок пустого состояния.

```vue
<template>
  <B24Empty title="Проекты не найдены" />
</template>
```

> [!TIP]
> По умолчанию заголовок отрисовывается как `h2`. Чтобы изменить тег, передайте в пропс `as` объект: например, `:as="{ title: 'h3' }"`. Так же можно задать корневой элемент: `:as="{ root: 'section', title: 'h3' }"`.

### Описание

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

```vue
<template>
  <B24Empty title="Проекты не найдены" description="Похоже, вы ещё не добавили ни одного проекта. Создайте проект, чтобы начать." />
</template>
```

### Иконка

Пропс `icon` задаёт иконку пустого состояния.

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

<template>
  <B24Empty :icon="RocketIcon" title="Проекты не найдены" description="Похоже, вы ещё не добавили ни одного проекта. Создайте проект, чтобы начать." />
</template>
```

### Загрузка

Пропс `loading` показывает иконку загрузки вместо обычной иконки. Раскладка при этом не меняется, поэтому между состояниями загрузки и пустоты можно переключаться без сдвигов.

```vue
<template>
  <B24Empty loading title="Загрузка проектов" description="Подождите, мы загружаем ваши проекты." />
</template>
```

### Иконка загрузки

Пропс `loading-icon` меняет иконку загрузки. По умолчанию `icons.loading`.

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

<template>
  <B24Empty loading :loading-icon="RocketIcon" title="Загрузка проектов" description="Подождите, мы загружаем ваши проекты." />
</template>
```

### Действия

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

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

<template>
  <B24Empty :icon="RocketIcon" title="Проекты не найдены" description="Похоже, вы ещё не добавили ни одного проекта. Создайте проект, чтобы начать." :actions="{'0':{label:'Создать',color:'air-primary'},'1':{label:'Обновить'}}" />
</template>
```

### Цвет

Пропс `color` меняет цвет пустого состояния.

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

<template>
  <B24Empty color="air-secondary-accent-2" :icon="RocketIcon" title="Уведомлений нет" description="Вы всё прочитали. Новые уведомления появятся здесь." :actions="{'0':{label:'Обновить'}}" />
</template>
```

### Инверсия

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

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

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

<template>
  <B24Empty inverted color="air-primary" :icon="RocketIcon" title="Уведомлений нет" description="Вы всё прочитали. Новые уведомления появятся здесь." :actions="{'0':{label:'Обновить'}}" />
</template>
```

### Размер

Пропс `size` меняет размер пустого состояния.

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

<template>
  <B24Empty size="xl" :icon="RocketIcon" title="Уведомлений нет" description="Вы всё прочитали. Новые уведомления появятся здесь." :actions="{'0':{label:'Обновить'}}" />
</template>
```

## Примеры

### Со слотами

Слоты позволяют собрать более сложное пустое состояние.

```vue [EmptySlotsExample.vue]
<script setup lang="ts">
import type { UserProps } from '@bxshefby/b24ui-nuxt'
import AddProductIcon from '@bitrix24/b24icons-vue/outline/AddProductIcon'

const members: UserProps[] = [
  {
    name: 'Имя сотрудника',
    description: 'Сотрудник команды',
    to: 'https://github.com/bitrix24',
    target: '_blank',
    avatar: {
      src: '/b24ui/avatar/employee.png',
      alt: 'Имя сотрудника',
      loading: 'lazy' as const
    }
  },
  {
    name: 'Имя сотрудника',
    description: 'Ассистент команды',
    to: 'https://github.com/bitrix24',
    target: '_blank',
    avatar: {
      src: '/b24ui/avatar/assistant.png',
      alt: 'Имя ассистента',
      loading: 'lazy' as const
    }
  }
]
</script>

<template>
  <B24Empty
    title="Нет участников команды"
    description="Пригласите команду для совместной работы над проектом."
    :actions="[{
      label: 'Пригласить участников',
      icon: AddProductIcon
    }]"
  >
    <template #leading>
      <B24AvatarGroup size="xl">
        <B24Avatar src="/b24ui/avatar/employee.png" alt="Имя сотрудника" loading="lazy" />
        <B24Avatar src="https://github.com/bitrix24.png" alt="bitrix24" loading="lazy" />
      </B24AvatarGroup>
    </template>

    <template #footer>
      <B24Separator class="my-4" />

      <div class="grid grid-cols-2 gap-4">
        <B24Card
          v-for="(member, index) in members"
          :key="index"
          :b24ui="{ body: 'p-4 sm:p-4' }"
        >
          <B24User
            :avatar="member.avatar"
            :name="member.name"
            :description="member.description"
            :b24ui="{ name: 'truncate' }"
          />
          <div class="mt-2 w-full flex flex-row justify-end">
            <B24Link
              class="text-xs"
              is-action
              :to="member.to"
              :target="member.target"
            >
              Пригласить
            </B24Link>
          </div>
        </B24Card>
      </div>
    </template>
  </B24Empty>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the Empty component
 */
interface EmptyProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * The icon displayed above the title.
   */
  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;
  /**
   * When `true`, the loading icon will be displayed.
   */
  loading?: boolean | undefined;
  /**
   * The icon when the `loading` prop is `true`.
   * @default icons.loading
   */
  loadingIcon?: (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;
  title?: string | undefined;
  description?: string | undefined;
  /**
   * Display a list of Button in the body.
   */
  actions?: ButtonProps[] | 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;
  /**
   * @default 'md'
   */
  size?: "md" | "xs" | "sm" | "lg" | "xl" | undefined;
  b24ui?: { root?: SlotClass; header?: SlotClass; indicator?: SlotClass; icon?: SlotClass; title?: SlotClass; description?: SlotClass; body?: SlotClass; actions?: SlotClass; footer?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the Empty component
 */
interface EmptySlots {
  header(): any;
  leading(): any;
  title(): any;
  description(): any;
  body(): any;
  actions(): any;
  footer(): any;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    empty: {
      slots: {
        root: 'relative flex flex-col items-center justify-center gap-4 rounded-lg p-4 sm:p-6 lg:p-8 min-w-0 bg-(--b24ui-background) ring ring-(--b24ui-border-color) ring-(length:--b24ui-border-width)',
        header: 'flex flex-col items-center gap-2 max-w-[384px] text-center',
        indicator: 'rounded-full text-(--b24ui-color) bg-(--b24ui-background-active) flex items-center justify-center mb-2',
        icon: 'shrink-0',
        title: 'text-(--b24ui-color) text-pretty font-(--ui-font-weight-medium)',
        description: 'text-balance text-center text-(--b24ui-color)',
        body: 'flex flex-col items-center gap-4 max-w-[384px]',
        actions: 'flex flex-wrap justify-center gap-2 shrink-0',
        footer: 'flex flex-col items-center gap-2 max-w-[384px]'
      },
      variants: {
        size: {
          xs: {
            icon: 'size-[26px]',
            title: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-lg)',
            description: 'text-(length:--ui-font-size-xs)'
          },
          sm: {
            icon: 'size-[28px]',
            title: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-lg)',
            description: 'text-(length:--ui-font-size-xs)'
          },
          md: {
            icon: 'size-[38px]',
            title: 'text-base',
            description: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-lg)'
          },
          lg: {
            icon: 'size-[44px]',
            title: 'text-base',
            description: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-lg)'
          },
          xl: {
            icon: 'size-[56px]',
            title: 'text-(length:--ui-font-size-xl)/(--ui-font-line-height-3xs)',
            description: 'text-(length:--ui-font-size-lg)/(--ui-font-line-height-3xs)'
          }
        },
        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'
          }
        },
        inverted: {
          true: '',
          false: ''
        },
        loading: {
          true: {
            icon: 'animate-spin'
          }
        }
      },
      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.
