---
title: "Listbox"
description: "Выбираемый список с поиском, виртуализацией и богатым отображением элементов."
canonical_url: "https://b24-ui.bx-shef.by/docs/components/listbox"
---
# Listbox

> Выбираемый список с поиском, виртуализацией и богатым отображением элементов.

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

Директива `v-model` управляет значением Listbox, а пропс `default-value` задаёт начальное значение, когда управлять состоянием не нужно.

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  },
  {
    label: 'Italy',
    value: 'IT'
  },
  {
    label: 'Spain',
    value: 'ES'
  },
  {
    label: 'Netherlands',
    value: 'NL'
  },
  {
    label: 'Poland',
    value: 'PL'
  },
  {
    label: 'Belgium',
    value: 'BE'
  },
  {
    label: 'Portugal',
    value: 'PT'
  },
  {
    label: 'Austria',
    value: 'AT'
  }
])
const value = ref({
  label: 'France',
  value: 'FR'
})
</script>

<template>
  <B24Listbox v-model="value" :items="items" />
</template>
```

### Элементы

Пропс `items` — массив объектов со свойствами:

- `label?: string`
- [`description?: string`](#with-description-in-items)
- [`type?: "label" | "separator" | "item"`](#with-items-type)
- [`icon?: IconComponent`](#with-icon-in-items)
- [`avatar?: AvatarProps`](#with-avatar-in-items)
- [`chip?: ChipProps`](#with-chip-in-items)
- `disabled?: boolean`
- `onSelect?: (e: Event) => void`
- `class?: any`
- `b24ui?: { label?: ClassNameValue, separator?: ClassNameValue, item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, ... }`

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    description: 'The Hexagon',
    value: 'FR'
  },
  {
    label: 'Germany',
    description: 'The Federal Republic',
    value: 'DE'
  },
  {
    label: 'Italy',
    description: 'The Boot',
    value: 'IT'
  },
  {
    label: 'Spain',
    description: 'The Bull Skin',
    value: 'ES'
  }
])
</script>

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

В пропс `items` можно передать и массив массивов, чтобы показать группы элементов, разделённые между собой.

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

const items = ref<ListboxItem[][]>([
  [
    {
      label: 'France',
      value: 'FR'
    },
    {
      label: 'Germany',
      value: 'DE'
    },
    {
      label: 'Italy',
      value: 'IT'
    }
  ],
  [
    {
      label: 'Brazil',
      value: 'BR'
    },
    {
      label: 'Argentina',
      value: 'AR'
    }
  ]
])
</script>

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

### Множественный выбор

Пропс `multiple` разрешает выбрать несколько элементов. Тогда `v-model` становится массивом.

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  },
  {
    label: 'Italy',
    value: 'IT'
  },
  {
    label: 'Spain',
    value: 'ES'
  }
])
</script>

<template>
  <B24Listbox multiple :items="items" />
</template>
```

### Ключ значения

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

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  },
  {
    label: 'Italy',
    value: 'IT'
  },
  {
    label: 'Spain',
    value: 'ES'
  }
])
const value = ref('FR')
</script>

<template>
  <B24Listbox v-model="value" value-key="value" :items="items" class="w-full" />
</template>
```

### Фильтр

Пропс `filter` показывает поле фильтра или принимает объект для настройки компонента [Input](https://b24-ui.bx-shef.by/raw/docs/components/input.md). По умолчанию `false`.

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  },
  {
    label: 'Italy',
    value: 'IT'
  },
  {
    label: 'Spain',
    value: 'ES'
  },
  {
    label: 'Netherlands',
    value: 'NL'
  },
  {
    label: 'Poland',
    value: 'PL'
  }
])
</script>

<template>
  <B24Listbox :filter="{placeholder:'Фильтр...'}" :items="items" />
</template>
```

### Иконка выбранного элемента

Пропс `selected-icon` меняет иконку выбранного элемента.

```vue
<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
import type { ListboxItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  },
  {
    label: 'Italy',
    value: 'IT'
  },
  {
    label: 'Spain',
    value: 'ES'
  }
])
const value = ref('FR')
</script>

<template>
  <B24Listbox v-model="value" :selected-icon="RocketIcon" value-key="value" :items="items" class="w-full" />
</template>
```

### Размер

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

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  },
  {
    label: 'Italy',
    value: 'IT'
  },
  {
    label: 'Spain',
    value: 'ES'
  }
])
</script>

<template>
  <B24Listbox size="xl" :items="items" />
</template>
```

### Загрузка

Пропс `loading` показывает индикатор загрузки, а пропс `loading-icon` меняет его иконку.

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  }
])
</script>

<template>
  <B24Listbox loading :items="items" />
</template>
```

### Отключение

Пропс `disabled` блокирует любое взаимодействие пользователя с Listbox.

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    value: 'FR'
  },
  {
    label: 'Germany',
    value: 'DE'
  },
  {
    label: 'Italy',
    value: 'IT'
  },
  {
    label: 'Spain',
    value: 'ES'
  }
])
</script>

<template>
  <B24Listbox disabled :items="items" />
</template>
```

## Примеры

### С типом элемента

Свойство `type` со значением `separator` показывает разделитель между элементами, а со значением `label` — подпись.

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

const items = ref<ListboxItem[][]>([
  [
    {
      type: 'label',
      label: 'Fruits'
    },
    {
      label: 'Apple'
    },
    {
      label: 'Banana'
    },
    {
      label: 'Blueberry'
    },
    {
      label: 'Grapes'
    },
    {
      label: 'Pineapple'
    }
  ],
  [
    {
      type: 'label',
      label: 'Vegetables'
    },
    {
      label: 'Aubergine'
    },
    {
      label: 'Broccoli'
    },
    {
      label: 'Carrot'
    },
    {
      label: 'Courgette'
    },
    {
      label: 'Leek'
    }
  ]
])
</script>

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

> [!NOTE]
> Если `label` используется как заголовок группы, передайте массив массивов: тогда при поиске подпись исчезает вместе со своей группой.

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

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

```vue [ListboxItemsIconExample.vue]
<script setup lang="ts">
import type { ListboxItem } from '@bxshefby/b24ui-nuxt'
import CircleCheckIcon from '@bitrix24/b24icons-vue/outline/CircleCheckIcon'
import CirclePlusIcon from '@bitrix24/b24icons-vue/outline/CirclePlusIcon'
import InfoCircleIcon from '@bitrix24/b24icons-vue/outline/InfoCircleIcon'
import SyncCircleIcon from '@bitrix24/b24icons-vue/main/SyncCircleIcon'

const items = ref<ListboxItem[]>([
  {
    label: 'Бэклог',
    icon: InfoCircleIcon,
    value: 'backlog'
  },
  {
    label: 'К выполнению',
    icon: CirclePlusIcon,
    value: 'todo'
  },
  {
    label: 'В работе',
    icon: SyncCircleIcon,
    value: 'in_progress'
  },
  {
    label: 'Готово',
    icon: CircleCheckIcon,
    value: 'done'
  }
])
</script>

<template>
  <B24Listbox :items="items" class="w-full" />
</template>
```

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

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

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

const items = ref<ListboxItem[]>([
  {
    label: 'Ассистент',
    avatar: {
      src: '/b24ui/avatar/assistant.png'
    }
  },
  {
    label: 'Сотрудник',
    avatar: {
      src: '/b24ui/avatar/employee.png'
    }
  },
  {
    label: 'Bitrix24',
    avatar: {
      src: 'https://github.com/bitrix24.png'
    }
  }
])
</script>

<template>
  <B24Listbox :items="items" class="w-full" />
</template>
```

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

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

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

const items = ref<ListboxItem[]>([
  {
    label: 'Ошибка',
    chip: {
      color: 'air-primary-alert'
    }
  },
  {
    label: 'Функция',
    chip: {
      color: 'air-primary-success'
    }
  },
  {
    label: 'Улучшение',
    chip: {
      color: 'air-primary'
    }
  }
])
</script>

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

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

Свойство `description` показывает дополнительный текст под подписью.

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

const items = ref<ListboxItem[]>([
  {
    label: 'France',
    description: 'The Hexagon',
    value: 'FR'
  },
  {
    label: 'Germany',
    description: 'The Federal Republic',
    value: 'DE'
  },
  {
    label: 'Italy',
    description: 'The Boot',
    value: 'IT'
  },
  {
    label: 'Spain',
    description: 'The Bull Skin',
    value: 'ES'
  }
])
</script>

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

### Управление выбранными элементами

Выбранным элементом управляют пропс `default-value` или директива `v-model`.

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

const items: ListboxItem[] = [
  { label: 'Франция', icon: Location1Icon, value: 'FR' },
  { label: 'Германия', icon: Location1Icon, value: 'DE' },
  { label: 'Италия', icon: Location1Icon, value: 'IT' },
  { label: 'Испания', icon: Location1Icon, value: 'ES' },
  { label: 'Нидерланды', icon: Location1Icon, value: 'NL' },
  { label: 'Польша', icon: Location1Icon, value: 'PL' }
]

const value = ref<ListboxItem>(items[2]!)
</script>

<template>
  <B24Listbox
    v-model="value"
    :items="items"
    class="w-full"
  />
</template>
```

### Управление поисковым запросом

Директива `v-model:search-term` управляет поисковым запросом.

```vue [ListboxSearchTermExample.vue]
<script setup lang="ts">
import Location1Icon from '@bitrix24/b24icons-vue/main/Location1Icon'

const searchTerm = ref('F')
const items = ref([
  { label: 'Франция', icon: Location1Icon, value: 'FR' },
  { label: 'Германия', icon: Location1Icon, value: 'DE' },
  { label: 'Италия', icon: Location1Icon, value: 'IT' },
  { label: 'Испания', icon: Location1Icon, value: 'ES' },
  { label: 'Нидерланды', icon: Location1Icon, value: 'NL' },
  { label: 'Польша', icon: Location1Icon, value: 'PL' }
])
const value = ref()
</script>

<template>
  <B24Listbox v-model="value" v-model:search-term="searchTerm" filter :items="items" class="w-full" />
</template>
```

### С отключённым фильтром

Пропс `ignore-filter` со значением `true` отключает внутренний поиск, и вы можете использовать собственную логику поиска.

```vue [ListboxIgnoreFilterExample.vue]
<script setup lang="ts">
import { refDebounced } from '@vueuse/core'
import CrmSearchIcon from '@bitrix24/b24icons-vue/crm/CrmSearchIcon'

const searchTerm = ref('')
const searchTermDebounced = refDebounced(searchTerm, 200)

const { data: users, status, execute } = await useLazyFetch('https://jsonplaceholder.typicode.com/users', {
  key: 'listbox-users-search',
  query: { q: searchTermDebounced },
  transform: (data: { id: number, name: string }[]) => {
    return data?.map(user => ({
      label: user.name,
      value: String(user.id),
      avatar: { src: `https://i.pravatar.cc/120?img=${user.id}`, loading: 'lazy' as const }
    }))
  },
  immediate: false
})

onMounted(() => {
  execute()
})
</script>

<template>
  <B24Listbox
    v-model:search-term="searchTerm"
    :items="users || []"
    :filter="{
      icon: CrmSearchIcon,
      loading: status === 'pending'
    }"
    ignore-filter
    class="w-full"
  />
</template>
```

> [!NOTE]
> В примере запросы к API откладываются через [`refDebounced`](https://vueuse.org/shared/refDebounced/#refdebounced).

### С полями фильтрации

Пропс `filter-fields` принимает массив полей, по которым выполняется фильтрация. По умолчанию `[labelKey]`.

```vue [ListboxFilterFieldsExample.vue]
<script setup lang="ts">
const { data: users, status, execute } = await useLazyFetch('https://jsonplaceholder.typicode.com/users', {
  key: 'typicode-users-email',
  transform: (data: { id: number, name: string, email: string }[]) => {
    return data?.map(user => ({
      label: user.name,
      email: user.email,
      value: String(user.id),
      avatar: { src: `https://i.pravatar.cc/120?img=${user.id}`, loading: 'lazy' as const }
    }))
  },
  immediate: false
})

onMounted(() => {
  execute()
})
</script>

<template>
  <B24Listbox
    :items="users || []"
    :loading="status === 'pending'"
    :filter-fields="['label', 'email']"
    filter
    class="w-full"
  >
    <template #item-label="{ item }">
      {{ item.label }}

      <span class="text-muted">
        {{ item.email }}
      </span>
    </template>
  </B24Listbox>
</template>
```

### С виртуализацией

Пропс `virtualize` включает виртуализацию для больших списков: булево значение или объект с параметрами вроде `{ estimateSize: 32, overscan: 12 }`.

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

const items: ListboxItem[] = Array.from({ length: 1000 }, (_, i) => ({
  label: `Элемент ${i + 1}`,
  icon: FileIcon,
  value: i + 1
}))

const value = ref<ListboxItem[]>([])
</script>

<template>
  <B24Listbox
    v-model="value"
    :items="items"
    multiple
    virtualize
    class="w-full"
  />
</template>
```

### Как список переноса

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

```vue [ListboxTransferListExample.vue]
<script setup lang="ts">
import type { ListboxItem } from '@bxshefby/b24ui-nuxt'
import Location1Icon from '@bitrix24/b24icons-vue/main/Location1Icon'
import ChevronLeftLIcon from '@bitrix24/b24icons-vue/outline/ChevronLeftLIcon'
import ChevronRightLIcon from '@bitrix24/b24icons-vue/outline/ChevronRightLIcon'

const items: ListboxItem[] = [
  { label: 'Франция', icon: Location1Icon, value: 'FR' },
  { label: 'Германия', icon: Location1Icon, value: 'DE' },
  { label: 'Италия', icon: Location1Icon, value: 'IT' },
  { label: 'Испания', icon: Location1Icon, value: 'ES' },
  { label: 'Нидерланды', icon: Location1Icon, value: 'NL' },
  { label: 'Польша', icon: Location1Icon, value: 'PL' },
  { label: 'Бельгия', icon: Location1Icon, value: 'BE' },
  { label: 'Португалия', icon: Location1Icon, value: 'PT' }
]

const targetItems = ref<ListboxItem[]>([])
const sourceSelection = ref<ListboxItem[]>([])
const targetSelection = ref<ListboxItem[]>([])

const sourceItems = computed(() => items.filter(item => !targetItems.value.some(t => t.value === item.value)))

function transferSelected() {
  targetItems.value = [...targetItems.value, ...sourceSelection.value]
  sourceSelection.value = []
}

function removeSelected() {
  targetItems.value = targetItems.value.filter(item => !targetSelection.value.some(t => t.value === item.value))
  targetSelection.value = []
}
</script>

<template>
  <div class="flex items-stretch gap-4 w-full">
    <div class="flex flex-col flex-1 gap-1">
      <span class="text-sm font-medium">Доступные</span>

      <B24Listbox
        v-model="sourceSelection"
        :items="sourceItems"
        multiple
        filter
        class="size-full"
      />
    </div>

    <div class="flex flex-col items-center justify-center gap-1">
      <B24Button
        :icon="ChevronRightLIcon"
        :disabled="!sourceSelection.length"
        @click="transferSelected"
      />
      <B24Button
        :icon="ChevronLeftLIcon"
        :disabled="!targetSelection.length"
        @click="removeSelected"
      />
    </div>

    <div class="flex flex-col flex-1 gap-1">
      <span class="text-sm font-medium text-legend">Выбранные</span>

      <B24Listbox
        v-model="targetSelection"
        :items="targetItems"
        multiple
        filter
        class="size-full"
      />
    </div>
  </div>
</template>
```

## API

### Пропсы

```ts
/**
 * Props for the Listbox component
 */
interface ListboxProps {
  id?: string | undefined;
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * @default 'air-primary'
   */
  color?: "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot";
  /**
   * @default 'md'
   */
  size?: "sm" | "md" | "xs" | "lg" | "xss" | "xl" | undefined;
  /**
   * The items to display in the list.
   */
  items?: T | undefined;
  /**
   * The controlled value of the Listbox. Can be bound with `v-model`.
   */
  modelValue?: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, undefined>, Mod>, Mod>, Mod> | undefined;
  modelModifiers?: Mod | undefined;
  /**
   * The default value when not controlled.
   */
  defaultValue?: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, undefined>, Mod>, Mod>, Mod> | undefined;
  /**
   * Whether multiple items can be selected.
   * @default false
   */
  multiple?: M | undefined;
  /**
   * When `items` is an array of objects, select the field to use as the value instead of the object itself.
   * @default undefined
   */
  valueKey?: VK | undefined;
  /**
   * The key used to get the label from the item.
   * @default 'label'
   */
  labelKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
  /**
   * The key used to get the description from the item.
   * @default 'description'
   */
  descriptionKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
  /**
   * Whether the list is in a loading state.
   */
  loading?: boolean | undefined;
  /**
   * The icon displayed when loading.
   * @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;
  /**
   * Whether to display a filter input or not.
   * Can be an object to pass additional props to the input.
   * `{ placeholder: 'Search...', variant: 'none' }`
   * @default false
   */
  filter?: boolean | Omit<InputProps<AcceptableValue, ModelModifiers>, "modelValue" | "defaultValue"> | undefined;
  /**
   * The fields to filter by.
   * @default [labelKey]
   */
  filterFields?: string[] | undefined;
  /**
   * When `true`, disable the default filters, useful for custom filtering (useAsyncData, useFetch, etc.).
   * @default false
   */
  ignoreFilter?: boolean | undefined;
  /**
   * The icon displayed when an item is selected.
   * @default icons.check
   */
  selectedIcon?: (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;
  /**
   * Enable virtualization for large lists.
   * @default false
   */
  virtualize?: boolean | { overscan?: number | undefined; estimateSize?: number | ((index: number) => number) | undefined; } | undefined;
  /**
   * Highlight the ring color like a focus state.
   */
  highlight?: boolean | undefined;
  autofocus?: boolean | undefined;
  /**
   * @default 0
   */
  autofocusDelay?: number | undefined;
  b24ui?: { root?: SlotClass; input?: SlotClass; content?: SlotClass; group?: SlotClass; label?: SlotClass; separator?: SlotClass; empty?: SlotClass; loading?: SlotClass; loadingIcon?: SlotClass; item?: SlotClass; itemLeadingIcon?: SlotClass; itemLeadingAvatar?: SlotClass; itemLeadingAvatarSize?: SlotClass; itemLeadingChip?: SlotClass; itemLeadingChipSize?: SlotClass; itemWrapper?: SlotClass; itemLabel?: SlotClass; itemDescription?: SlotClass; itemTrailing?: SlotClass; itemTrailingIcon?: SlotClass; } | undefined;
  /**
   * Use this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared.
   */
  by?: string | (a: AcceptableValue, b: AcceptableValue): boolean | undefined;
  /**
   * When `true`, prevents the user from interacting with listbox
   */
  disabled?: boolean | undefined;
  /**
   * When `true`, hover over item will trigger highlight
   * @default true
   */
  highlightOnHover?: boolean | undefined;
  /**
   * When `true`, keyboard navigation will loop from last item to first, and vice versa.
   */
  loop?: boolean | undefined;
  /**
   * The name of the field. Submitted with its owning form as part of a name/value pair.
   */
  name?: string | undefined;
  /**
   * The orientation of the listbox. <br>Mainly so arrow navigation is done accordingly (left & right vs. up & down)
   */
  orientation?: "vertical" | "horizontal" | undefined;
  /**
   * When `true`, indicates that the user must set the value before the owning form can be submitted.
   */
  required?: boolean | undefined;
  /**
   * How multiple selection should behave in the collection.
   * @default 'toggle'
   */
  selectionBehavior?: "replace" | "toggle" | undefined;
  /**
   * @default ''
   */
  searchTerm?: string | undefined;
}
```

### Слоты

```ts
/**
 * Slots for the Listbox component
 */
interface ListboxSlots {
  loading(): any;
  empty(): any;
  item(): any;
  item-leading(): any;
  item-label(): any;
  item-description(): any;
  item-trailing(): any;
}
```

### События

```ts
/**
 * Emitted events for the Listbox component
 */
interface ListboxEmits {
  entryFocus: (payload: [event: CustomEvent<any>]) => void;
  highlight: (payload: [payload: { ref: HTMLElement; value: AcceptableValue; } | undefined]) => void;
  leave: (payload: [event: Event]) => void;
  change: (payload: [event: Event]) => void;
  update:modelValue: (payload: [value: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, undefined>, Mod>, Mod>, Mod>]) => void;
  update:searchTerm: (payload: [value: string]) => void;
}
```

## Тема

```ts [app.config.ts]
export default defineAppConfig({
  b24ui: {
    listbox: {
      slots: {
        root: 'flex flex-col min-h-0 min-w-0 ring ring-inset ring-(--ui-color-design-outline-stroke) rounded-lg overflow-hidden outline-(--b24ui-border-color) has-focus-visible:outline-3 has-focus-visible:ring-(--b24ui-border-color)',
        input: 'border-b border-(--ui-color-design-outline-stroke) has-focus-visible:border-(--b24ui-border-color)',
        content: 'relative overflow-y-auto flex-1 max-h-60 scroll-py-1 focus:outline-none',
        group: 'isolate',
        label: 'w-full min-w-[195px] h-(--popup-window-delimiter-section-height) px-4.5 mt-(--menu-item-block-stack-space) flex flex-row rtl:flex-row-reverse items-center select-none outline-none whitespace-nowrap text-start text-(length:--ui-size-sm) text-legend font-(--ui-font-weight-normal) after:ms-[10px] after:block after:flex-1 after:min-w-[15px] after:h-px after:bg-(--ui-color-divider-vibrant-default)',
        separator: 'my-2 mx-4.5 h-[1px] bg-(--ui-color-divider-vibrant-default)',
        empty: 'py-2 select-none outline-none whitespace-nowrap text-center text-(length:--popup-window-delimiter-font-size)/(--ui-font-line-height-lg) text-legend font-(--ui-font-weight-normal)',
        loading: 'flex items-center justify-center text-muted',
        loadingIcon: 'shrink-0',
        item: 'group relative w-full flex items-start select-none outline-none before:absolute before:z-[-1] before:inset-0 data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-label data-[state=checked]:text-label data-highlighted:not-data-disabled:before:bg-(--ui-color-base-black-fixed)/3 dark:data-highlighted:not-data-disabled:before:bg-(--ui-color-base-black-fixed) transition-colors before:transition-colors',
        itemLeadingIcon: 'size-[25px] shrink-0 text-(--ui-color-base-5)',
        itemLeadingAvatar: 'shrink-0',
        itemLeadingAvatarSize: '',
        itemLeadingChip: 'shrink-0',
        itemLeadingChipSize: '',
        itemWrapper: 'flex-1 flex flex-col min-w-0',
        itemLabel: 'truncate',
        itemDescription: 'truncate -mt-[6px] text-description text-(length:--ui-font-size-sm)',
        itemTrailing: 'ml-auto rtl:ml-0 rtl:mr-auto inline-flex gap-1.5 items-center',
        itemTrailingIcon: 'shrink-0 text-(--ui-color-accent-main-primary)'
      },
      variants: {
        size: {
          xss: {
            label: 'p-1 text-[10px]/3 gap-1',
            empty: 'py-3 text-[10px]',
            loading: 'py-3',
            loadingIcon: 'size-2',
            item: 'p-1 text-[10px] gap-1',
            itemLeadingIcon: 'size-3 mt-0.5',
            itemLeadingAvatar: 'size-3 mt-0.5',
            itemLeadingAvatarSize: '3xs',
            itemLeadingChip: 'size-3 mt-0.5',
            itemLeadingChipSize: '2xs',
            itemTrailingIcon: 'size-3 mt-0.5'
          },
          xs: {
            label: 'p-1 text-[10px]/3 gap-1',
            empty: 'py-3 text-[12px]',
            loading: 'py-3',
            loadingIcon: 'size-[12px]',
            item: 'p-1 text-[12px] gap-1',
            itemLeadingIcon: 'size-4 mt-0.5',
            itemLeadingAvatar: 'size-4 mt-0.5',
            itemLeadingAvatarSize: '3xs',
            itemLeadingChip: 'size-3 mt-0.5',
            itemLeadingChipSize: 'sm',
            itemTrailingIcon: 'size-4 mt-0.5'
          },
          sm: {
            label: 'p-1.5 text-[10px]/3 gap-1.5',
            empty: 'py-4 text-[14px]',
            loading: 'py-4',
            loadingIcon: 'size-4',
            item: 'p-1.5 text-[14px] gap-1.5',
            itemLeadingIcon: 'size-5',
            itemLeadingAvatar: 'size-5',
            itemLeadingAvatarSize: '3xs',
            itemLeadingChip: 'size-4 mt-1',
            itemLeadingChipSize: 'sm',
            itemTrailingIcon: 'size-5'
          },
          md: {
            label: 'px-4.5 py-1.5 text-xs gap-1.5',
            empty: 'py-6 text-(length:--ui-font-size-xl)',
            loading: 'py-6',
            loadingIcon: 'size-6',
            item: 'px-4.5 py-1.5 text-(length:--ui-font-size-xl) gap-1.5',
            itemLeadingIcon: 'size-6',
            itemLeadingAvatar: 'size-6',
            itemLeadingAvatarSize: '2xs',
            itemLeadingChip: 'size-5 mt-1',
            itemLeadingChipSize: 'md',
            itemTrailingIcon: 'size-6'
          },
          lg: {
            label: 'p-2 text-xs gap-2',
            empty: 'py-7 text-(length:--ui-font-size-xl)',
            loading: 'py-7',
            loadingIcon: 'size-8',
            item: 'p-2 text-(length:--ui-font-size-xl) gap-2',
            itemLeadingIcon: 'size-7',
            itemLeadingAvatar: 'size-7',
            itemLeadingAvatarSize: '2xs',
            itemLeadingChip: 'size-5 mt-1',
            itemLeadingChipSize: 'md',
            itemTrailingIcon: 'size-6'
          },
          xl: {
            label: 'p-2 text-(length:--ui-font-size-xl) gap-2',
            empty: 'py-8 text-(length:--ui-font-size-4xl)',
            loading: 'py-8',
            loadingIcon: 'size-10',
            item: 'p-2 text-(length:--ui-font-size-4xl) gap-2',
            itemLeadingIcon: 'size-7',
            itemLeadingAvatar: 'size-7',
            itemLeadingAvatarSize: 'xs',
            itemLeadingChip: 'size-6',
            itemLeadingChipSize: 'lg',
            itemTrailingIcon: 'size-6',
            itemDescription: 'text-(length:--ui-font-size-xl)'
          }
        },
        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'
          }
        },
        virtualize: {
          true: {
            content: 'p-1 isolate'
          },
          false: {
            content: 'divide-y divide-(--ui-color-divider-default)'
          }
        },
        disabled: {
          true: {
            root: 'cursor-not-allowed opacity-30'
          }
        },
        highlight: {
          true: 'ring ring-inset ring-(--b24ui-border-color)'
        }
      },
      defaultVariants: {
        color: 'air-primary',
        size: 'md'
      }
    }
  }
})
```

## Sitemap

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