---
title: "DescriptionList"
description: "Список описаний: таблица из пар «название — значение» для полноты страницы."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/description-list"
---
# DescriptionList

> Список описаний: таблица из пар «название — значение» для полноты страницы.

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

Пропс `items` — массив объектов, который задаёт содержимое DescriptionList:

- `label?: string`
- `description?: string`
- [`icon?: IconComponent`](#with-icons-in-items)
- [`avatar?: AvatarProps`](#with-avatar-in-items)
- [`actions?: ButtonProps[]`](#with-actions-in-items)
- [`orientation?: "horizontal" | "vertical"`](#with-actions-in-items)
- [`slot?: string`](#with-custom-slot)
- `class?: any`
- `b24ui?: { labelWrapper?: ClassNameValue, icon?: ClassNameValue, avatar?: ClassNameValue, label?: ClassNameValue, descriptionWrapper?: ClassNameValue, description?: ClassNameValue, actions?: ClassNameValue }`

```vue
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

const items = ref<DescriptionListItem[]>([
  {
    label: 'Полное имя',
    description: 'Michael Foster'
  },
  {
    label: 'Событие',
    description: 'Оплата проходит через Atol Online'
  }
])
</script>

<template>
  <B24DescriptionList :items="items" />
</template>
```

### Легенда

Пропс `legend` задаёт легенду DescriptionList.

```vue
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

const items = ref<DescriptionListItem[]>([
  {
    label: 'Полное имя',
    description: 'Michael Foster'
  },
  {
    label: 'Событие',
    description: 'Оплата проходит через Atol Online'
  }
])
</script>

<template>
  <B24DescriptionList legend="Данные заявителя" :items="items" />
</template>
```

### Текст

Пропс `text` задаёт описание DescriptionList.

```vue
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

const items = ref<DescriptionListItem[]>([
  {
    label: 'Полное имя',
    description: 'Michael Foster'
  },
  {
    label: 'Событие',
    description: 'Оплата проходит через Atol Online'
  }
])
</script>

<template>
  <B24DescriptionList legend="Данные заявителя" text="Личные данные и заявка." :items="items" />
</template>
```

### Ключ подписи

Свойство объекта, из которого берётся подпись, меняет пропс `label-key`. По умолчанию `label`.

```vue
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

const items = ref<DescriptionListItem[]>([
  {
    title: 'Полное имя',
    description: 'Michael Foster'
  },
  {
    title: 'Событие',
    description: 'Оплата проходит через Atol Online'
  }
])
</script>

<template>
  <B24DescriptionList legend="Данные заявителя" text="Личные данные и заявка." label-key="title" :items="items" />
</template>
```

### Ключ описания

Свойство объекта, из которого берётся описание, меняет пропс `description-key`. По умолчанию `description`.

```vue
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

const items = ref<DescriptionListItem[]>([
  {
    title: 'Полное имя',
    info: 'Michael Foster'
  },
  {
    title: 'Событие',
    info: 'Оплата проходит через Atol Online'
  }
])
</script>

<template>
  <B24DescriptionList legend="Данные заявителя" text="Личные данные и заявка." label-key="title" description-key="info" :items="items" />
</template>
```

### Размер

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

```vue
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

const items = ref<DescriptionListItem[]>([
  {
    label: 'Полное имя',
    description: 'Michael Foster'
  },
  {
    label: 'Событие',
    description: 'Оплата проходит через Atol Online'
  }
])
</script>

<template>
  <B24DescriptionList size="sm" legend="Данные заявителя" text="Личные данные и заявка." :items="items" />
</template>
```

## Примеры

### С иконками в элементах

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

```vue [DescriptionListIconExample.vue]
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'
import SignIcon from '@bitrix24/b24icons-vue/main/SignIcon'
import PersonIcon from '@bitrix24/b24icons-vue/main/PersonIcon'

const items = ref([
  {
    label: 'Строка 1.1',
    description: 'Описание 1.1',
    icon: SignIcon
  },
  {
    label: 'Строка 1.2',
    description: 'Описание 1.2',
    avatar: {
      icon: PersonIcon
    }
  },
  {
    description: 'Описание 1.3',
    icon: SignIcon
  }
] satisfies DescriptionListItem[])
</script>

<template>
  <B24DescriptionList
    legend="Информация о кандидате"
    text="Личные данные и заявка."
    :items="items"
  />
</template>
```

### С аватарами в элементах

Свойство `avatar` показывает [аватар](https://b24-ui.bx-shef.by/raw/docs/components/avatar.md) внутри элементов.

```vue [DescriptionListAvatarExample.vue]
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

const items = ref([
  {
    label: 'Строка 1.1',
    description: 'Описание 1.1',
    avatar: {
      src: '/b24ui/avatar/employee.png',
      loading: 'lazy' as const
    }
  },
  {
    label: 'Строка 1.2',
    description: 'Описание 1.2',
    avatar: {
      src: '/b24ui/avatar/assistant.png',
      loading: 'lazy' as const
    }
  },
  {
    description: 'Описание 1.3',
    avatar: {
      src: 'https://github.com/bitrix24.png',
      loading: 'lazy' as const
    }
  }
] satisfies DescriptionListItem[])
</script>

<template>
  <B24DescriptionList
    legend="Информация о кандидате"
    text="Личные данные и заявка."
    :items="items"
  />
</template>
```

### С действиями в элементах

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

Свойство `orientation` меняет ориентацию действий элементов.

```vue [DescriptionListActionsExample.vue]
<script setup lang="ts">
import type { DescriptionListItem, ButtonProps } from '@bxshefby/b24ui-nuxt'
import SignIcon from '@bitrix24/b24icons-vue/main/SignIcon'
import DotsIcon from '@bitrix24/b24icons-vue/button/DotsIcon'

const action = (color: string): ButtonProps[] => [
  {
    icon: DotsIcon,
    color: color as any,
    onClick() {
      console.log('Действие нажато')
    }
  }
]

const multipleActions = (color: string): ButtonProps[] => [
  {
    label: 'Действие',
    color: color as any,
    onClick() {
      console.log('Действие нажато')
    }
  },
  {
    label: 'Другое действие',
    color: color as any,
    onClick() {
      console.log('Другое действие нажато')
    }
  },
  {
    label: 'Ещё одно действие',
    color: color as any,
    onClick() {
      console.log('Ещё одно действие нажато')
    }
  },
  {
    label: 'И ещё одно',
    color: color as any,
    icon: SignIcon,
    onClick() {
      console.log('И ещё одно нажато')
    }
  },
  {
    label: 'Последнее',
    color: color as any,
    icon: DotsIcon,
    onClick() {
      console.log('Последнее нажато')
    }
  }
]

const items = ref([
  {
    label: 'Строка 1.1',
    description: 'Описание 1.1',
    actions: action('air-secondary-no-accent'),
    orientation: 'horizontal' as DescriptionListItem['orientation']
  },
  {
    label: 'Строка 1.2',
    description: 'Описание 1.2',
    actions: action('air-primary'),
    orientation: 'horizontal' as DescriptionListItem['orientation']
  },
  {
    label: 'Строка 1.3',
    description: 'Описание 1.3',
    actions: action('air-tertiary-no-accent'),
    orientation: 'horizontal' as DescriptionListItem['orientation']
  },
  {
    description: 'Длинное описание строки: оно показывает, как текст переносится внутри списка описаний и остаётся читаемым, даже когда занимает несколько строк подряд.',
    actions: multipleActions('default'),
    orientation: 'vertical' as DescriptionListItem['orientation']
  }
] satisfies DescriptionListItem[])
</script>

<template>
  <B24DescriptionList
    legend="Информация о кандидате"
    text="Личные данные и заявка."
    :items="items"
  />
</template>
```

### Свой слот

Свойство `slot` настраивает отдельный элемент.

Вам будут доступны слоты:

- `#{{ item.slot }}`

```vue [DescriptionListCustomSlotExample.vue]
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'
import DownloadDoubleIcon from '@bitrix24/b24icons-vue/actions/DownloadDoubleIcon'
import PersonIcon from '@bitrix24/b24icons-vue/main/PersonIcon'
import Calendar1Icon from '@bitrix24/b24icons-vue/main/Calendar1Icon'
import CreditDebitCardIcon from '@bitrix24/b24icons-vue/main/CreditDebitCardIcon'

const items = ref([
  {
    id: 'amount',
    slot: 'amount',
    label: 'Сумма',
    value: '$10,560.00',
    description: 'Оплачено',
    b24ui: {
      label: 'font-(--ui-font-weight-semi-bold) text-(length:--ui-font-size-md)/(--ui-font-line-height-md)',
      description: 'font-(--ui-font-weight-semi-bold) text-(length:--ui-font-size-lg) block w-full'
    }
  },
  {
    id: 'client',
    label: 'Клиент',
    avatar: {
      icon: PersonIcon
    },
    description: 'Имя сотрудника',
    b24ui: {
      description: 'font-(--ui-font-weight-semi-bold)'
    }
  },
  {
    id: 'date',
    label: 'Срок',
    icon: Calendar1Icon,
    value: new Date('2023-01-31T03:24:00')
  },
  {
    id: 'payment',
    label: 'Способ оплаты',
    icon: CreditDebitCardIcon,
    description: 'Оплачено через MasterCard'
  }
] satisfies (DescriptionListItem & { id: string, value?: Date | string })[])
</script>

<template>
  <B24Card variant="tinted-success" class="w-full">
    <B24DescriptionList
      legend="Информация о кандидате"
      text="Личные данные и заявка."
      class="light"
      :items="items"
      :b24ui="{
        legend: 'sr-only',
        text: 'sr-only',
        labelWrapper: 'px-4',
        container: 'mt-0',
        descriptionWrapper: 'px-4',
        footer: 'mt-4 px-0 py-4 pb-0 flex flex-row flex-nowrap justify-end items-center'
      }"
    >
      <template #amount="{ index }">
        <dt class="col-start-1 flex flex-nowrap flex-row items-center justify-start gap-1.5 pt-2 sm:py-1 px-4">
          <ProseH4 class="mb-0">
            Сумма
          </ProseH4>
        </dt>
        <dd class="pb-3 pt-1 sm:py-3 px-4">
          <div class="flex flex-wrap flex-row items-center justify-start gap-4">
            <div>
              {{ items[index]?.value }}
            </div>
            <B24Badge
              :label="items[index]?.description"
              class="font-(--ui-font-weight-semi-bold)"
              color="air-primary-success"
            />
          </div>
        </dd>
      </template>
      <template #description="{ item }">
        <template v-if="item.id === 'date'">
          <time :datetime="(item?.value as Date)?.toISOString()">{{ (item?.value as Date)?.toDateString() }}</time>
        </template>
        <template v-else>
          {{ item.description }}
        </template>
      </template>
      <template #footer>
        <B24Button
          color="air-primary"
          label="Скачать чек"
          :icon="DownloadDoubleIcon"
          rounded
        />
      </template>
    </B24DescriptionList>
  </B24Card>
</template>
```

### Ссылка в описании

Слот `description` получает элемент, поэтому описание можно отрисовать как
[Link](https://b24-ui.bx-shef.by/raw/docs/components/link.md) без дополнительного свойства у элемента. Слот
общий, а не отдельный для каждого элемента, поэтому ветка по умолчанию
оставляет остальные элементы обычным текстом.

```vue [DescriptionListLinkSlotExample.vue]
<script setup lang="ts">
import type { DescriptionListItem } from '@bxshefby/b24ui-nuxt'

// `to` и `target` не входят в `DescriptionListItem`; индексная сигнатура
// передаёт их, чтобы слот `#description` мог их прочитать.
const items: DescriptionListItem[] = [
  {
    label: 'Документация',
    description: 'Руководство по началу работы',
    to: '/docs/getting-started'
  },
  {
    label: 'Сайт продукта',
    description: 'Открыть на bitrix24.com',
    to: 'https://www.bitrix24.com/',
    target: '_blank'
  },
  {
    label: 'Создано',
    description: '6 октября 2024 08:37'
  }
]
</script>

<template>
  <B24DescriptionList :items="items" size="sm">
    <template #description="{ item }">
      <B24Link
        v-if="item.to"
        :to="item.to"
        :target="item.target"
      >
        {{ item.description }}
      </B24Link>
      <template v-else>
        {{ item.description }}
      </template>
    </template>
  </B24DescriptionList>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the DescriptionList component
 */
interface DescriptionListProps {
  legend?: string | undefined;
  text?: string | undefined;
  /**
   * The key used to get the label from the item.
   * @default 'label'
   */
  labelKey?: string | undefined;
  /**
   * The key used to get the description from the item.
   * @default 'description'
   */
  descriptionKey?: string | undefined;
  items?: T[] | undefined;
  /**
   * @default 'md'
   */
  size?: "md" | "sm" | undefined;
  b24ui?: { root?: SlotClass; legend?: SlotClass; text?: SlotClass; container?: SlotClass; labelWrapper?: SlotClass; icon?: SlotClass; avatar?: SlotClass; avatarSize?: SlotClass; label?: SlotClass; descriptionWrapper?: SlotClass; description?: SlotClass; actions?: SlotClass; footer?: SlotClass; } | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the DescriptionList component
 */
interface DescriptionListSlots {
  legend(): any;
  text(): any;
  leading(): any;
  label(): any;
  description(): any;
  actions(): any;
  content-top(): any;
  content(): any;
  content-bottom(): any;
  footer(): any;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    descriptionList: {
      slots: {
        root: 'w-full shrink-0',
        legend: 'font-(--ui-font-weight-semi-bold) text-label',
        text: 'text-description',
        container: 'grid grid-cols-1 sm:grid-cols-[min(50%,theme(spacing.80))_auto]',
        labelWrapper: 'col-start-1 border-t first:border-none sm:border-t flex flex-nowrap flex-row items-center justify-start gap-1.5 border-(--ui-color-divider-vibrant-default) sm:border-(--ui-color-divider-vibrant-default) text-description',
        icon: 'shrink-0 size-6 text-description',
        avatar: 'shrink-0',
        avatarSize: '',
        label: '',
        descriptionWrapper: 'sm:border-t sm:[&:nth-child(2)]:border-none sm:border-(--ui-color-divider-vibrant-default) text-label',
        description: '',
        actions: 'flex flex-wrap gap-1.5 shrink-0',
        footer: 'border-t border-(--ui-color-divider-vibrant-default)'
      },
      variants: {
        size: {
          sm: {
            legend: 'text-md',
            text: 'mt-1 max-w-2/3 text-(length:--ui-font-size-sm)',
            container: 'mt-2.5 text-md',
            labelWrapper: 'pt-3 sm:py-3',
            avatarSize: 'xs',
            label: '',
            descriptionWrapper: 'pb-3 pt-1 sm:py-3',
            description: '',
            footer: 'mt-2 p-2'
          },
          md: {
            legend: 'text-xl',
            text: 'mt-2 max-w-2/3 text-(length:--ui-font-size-lg) leading-5',
            container: 'mt-3 text-(length:--ui-font-size-lg)',
            labelWrapper: 'pt-3 sm:py-3',
            avatarSize: 'xs',
            label: '',
            descriptionWrapper: 'pb-3 pt-1 sm:py-3',
            description: '',
            footer: 'mt-4 p-4'
          }
        },
        orientation: {
          horizontal: {
            descriptionWrapper: 'w-full flex flex-row items-center justify-between gap-4',
            actions: 'items-center'
          },
          vertical: {
            descriptionWrapper: '',
            actions: 'items-start mt-2.5'
          }
        },
        title: {
          true: {
            description: 'mt-1'
          }
        }
      },
      defaultVariants: {
        size: 'md'
      }
    }
  }
})
```

## Sitemap

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