v2.15.0

Select

Поле выбора одного значения из набора вариантов.

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

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

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :items="items" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

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

Элементы

Пропс items принимает массив строк, чисел или булевых значений:

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>

Можно передать и массив объектов со свойствами:

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

const items = ref<SelectItem[]>([
  {
    label: 'Backlog',
    value: 'backlog'
  },
  {
    label: 'Todo',
    value: 'todo'
  },
  {
    label: 'In Progress',
    value: 'in_progress'
  },
  {
    label: 'Done',
    value: 'done'
  }
])
const value = ref('backlog')
</script>

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectItem } from '@bxshefby/b24ui-nuxt'

const items = ref<SelectItem[]>([
  {
    label: 'Backlog',
    value: 'backlog'
  },
  {
    label: 'Todo',
    value: 'todo'
  },
  {
    label: 'In Progress',
    value: 'in_progress'
  },
  {
    label: 'Done',
    value: 'done'
  }
])
const value = ref('backlog')
</script>

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>
При использовании объектов в директиве v-model или пропсе default-value нужно указывать свойство value объекта.

В пропс items можно передать и массив массивов. Тип элемента separator задаёт разделитель.

<script setup lang="ts">
const items = ref([
  ['Apple', 'Banana', 'Blueberry', 'Grapes', 'Pineapple'],
  [
    {
      type: 'separator'
    },
    'Aubergine',
    'Broccoli',
    'Carrot',
    'Courgette',
    'Leek'
  ]
])
const value = ref('Apple')
</script>

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

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

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>

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

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

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

const items = ref<SelectItem[]>([
  {
    label: 'Backlog',
    id: 'backlog'
  },
  {
    label: 'Todo',
    id: 'todo'
  },
  {
    label: 'In Progress',
    id: 'in_progress'
  },
  {
    label: 'Done',
    id: 'done'
  }
])
const value = ref('todo')
</script>

<template>
  <B24Select v-model="value" value-key="id" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectItem } from '@bxshefby/b24ui-nuxt'

const items = ref<SelectItem[]>([
  {
    label: 'Backlog',
    id: 'backlog'
  },
  {
    label: 'Todo',
    id: 'todo'
  },
  {
    label: 'In Progress',
    id: 'in_progress'
  },
  {
    label: 'Done',
    id: 'done'
  }
])
const value = ref('todo')
</script>

<template>
  <B24Select v-model="value" value-key="id" :items="items" class="w-48" />
</template>
Слоты #leading, #default и #trailing получают выбранный элемент как item, поэтому остальные его свойства доступны, даже когда model-value хранит только ключ.

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

Пропс multiple разрешает выбрать несколько элементов; выбранные элементы показываются в триггере через запятую.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref(['Backlog', 'Todo'])
</script>

<template>
  <B24Select v-model="value" multiple :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref(['Backlog', 'Todo'])
</script>

<template>
  <B24Select v-model="value" multiple :items="items" class="w-48" />
</template>
В default-value или v-model нужно передать массив.

Плейсхолдер

Пропс placeholder задаёт текст плейсхолдера.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select placeholder="Выберите статус" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select placeholder="Выберите статус" :items="items" class="w-48" />
</template>

Содержимое

Пропс content управляет отрисовкой содержимого Select, например его align или side.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    :content="{
      align: 'center',
      side: 'bottom',
      sideOffset: 8
    }"
    :items="items"
    class="w-48"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    :content="{
      align: 'center',
      side: 'bottom',
      sideOffset: 8
    }"
    :items="items"
    class="w-48"
  />
</template>
Эти параметры действуют, только когда content.position равен popper (по умолчанию).

Позиция

Пропс content.position определяет, как содержимое Select позиционируется относительно триггера. По умолчанию popper: содержимое позиционируется как у остальных всплывающих окон. Значение item-aligned выравнивает содержимое по выбранному элементу (как в нативном меню macOS).

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Todo')
</script>

<template>
  <B24Select
    v-model="value"
    :content="{
      position: 'item-aligned'
    }"
    :items="items"
    class="w-48"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Todo')
</script>

<template>
  <B24Select
    v-model="value"
    :content="{
      position: 'item-aligned'
    }"
    :items="items"
    class="w-48"
  />
</template>

Стрелка

Пропс arrow показывает стрелку у Select.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" arrow :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" arrow :items="items" class="w-48" />
</template>

Цвет

Пропс color меняет цвет кольца, когда Select в фокусе.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" color="air-primary-copilot" highlight :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" color="air-primary-copilot" highlight :items="items" class="w-48" />
</template>
Пропс highlight здесь показывает состояние фокуса. Внутри компонента он включается при ошибке валидации.

Тег

Свойство tag показывает Badge поверх Select.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    tag="note"
    color="air-primary-warning"
    highlight
    placeholder="Поиск..."
    :items="items"
    class="w-48"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    tag="note"
    color="air-primary-warning"
    highlight
    placeholder="Поиск..."
    :items="items"
    class="w-48"
  />
</template>
Пропс highlight здесь показывает состояние фокуса. Внутри компонента он включается при ошибке валидации.

Свойство tagColor задаёт цвет Badge.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    tag="note"
    tag-color="air-secondary-alert"
    color="air-primary-warning"
    highlight
    placeholder="Поиск..."
    :items="items"
    class="w-48"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    tag="note"
    tag-color="air-secondary-alert"
    color="air-primary-warning"
    highlight
    placeholder="Поиск..."
    :items="items"
    class="w-48"
  />
</template>
Пропс highlight здесь показывает состояние фокуса. Внутри компонента он включается при ошибке валидации.

Размер

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

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" size="xl" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" size="xl" :items="items" class="w-48" />
</template>

Иконка

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

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

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :icon="RocketIcon" size="md" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :icon="RocketIcon" size="md" :items="items" class="w-48" />
</template>

Иконка справа

Пропс trailing-icon меняет иконку справа.

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

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :trailing-icon="RocketIcon" size="md" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :trailing-icon="RocketIcon" size="md" :items="items" class="w-48" />
</template>

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

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

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

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :selected-icon="RocketIcon" size="md" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" :selected-icon="RocketIcon" size="md" :items="items" class="w-48" />
</template>

Аватар

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

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    :avatar="{
      src: '/b24ui/avatar/employee.png',
      loading: 'lazy'
    }"
    :items="items"
    class="w-48"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select
    v-model="value"
    :avatar="{
      src: '/b24ui/avatar/employee.png',
      loading: 'lazy'
    }"
    :items="items"
    class="w-48"
  />
</template>

Загрузка

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

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" loading :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>

<template>
  <B24Select v-model="value" loading :items="items" class="w-48" />
</template>

Отключение

Пропс disabled отключает Select.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select disabled placeholder="Выберите статус" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select disabled placeholder="Выберите статус" :items="items" class="w-48" />
</template>

Без отступов

Пропс noPadding убирает у Select внутренние отступы.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select no-padding highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select no-padding highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
Пропс highlight здесь показывает состояние фокуса.

Без границы

Пропс noBorder убирает у Select все границы (кольца).

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select no-border highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select no-border highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
Пропс highlight здесь показывает, что состояния фокуса нет.

Подчёркивание

Пропс underline убирает у Select все границы (кольца), кроме нижней.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select underline highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select underline highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
Пропс highlight здесь показывает состояние фокуса.

Скругление

Пропс rounded скругляет Select.

<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select rounded highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
</script>

<template>
  <B24Select rounded highlight placeholder="Выберите статус" :items="items" class="w-48" />
</template>
Пропс highlight здесь показывает состояние фокуса.

Примеры

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

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

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

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

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectItem } from '@bxshefby/b24ui-nuxt'

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

<template>
  <B24Select v-model="value" :items="items" class="w-48" />
</template>

С цветными элементами

Свойство color меняет цвет элементов.

<script setup lang="ts">
import type { SelectItem } from '@bxshefby/b24ui-nuxt'
import SettingsIcon from '@bitrix24/b24icons-vue/main/SettingsIcon'
import MyPlanIcon from '@bitrix24/b24icons-vue/main/MyPlanIcon'
import Shield2DefendedIcon from '@bitrix24/b24icons-vue/main/Shield2DefendedIcon'

const items = ref([
  {
    label: 'Настройки CRM',
    value: 'settings',
    color: 'air-primary',
    icon: SettingsIcon
  },
  {
    label: 'Реквизиты моей компании',
    value: 'my_company_details',
    color: 'air-primary-success',
    icon: MyPlanIcon
  },
  {
    label: 'В работе',
    value: 'in_progress'
  },
  {
    label: 'Права доступа',
    value: 'access_permissions',
    color: 'air-primary-alert',
    icon: Shield2DefendedIcon
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)

const icon = computed(() => items.value.find(item => item.value === value.value)?.icon)
</script>

<template>
  <B24Select v-model="value" :icon="icon" :items="items" value-key="value" class="w-48" />
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import type { SelectItem } from '@bxshefby/b24ui-nuxt'
import SettingsIcon from '@bitrix24/b24icons-vue/main/SettingsIcon'
import MyPlanIcon from '@bitrix24/b24icons-vue/main/MyPlanIcon'
import Shield2DefendedIcon from '@bitrix24/b24icons-vue/main/Shield2DefendedIcon'

const items = ref([
  {
    label: 'Настройки CRM',
    value: 'settings',
    color: 'air-primary',
    icon: SettingsIcon
  },
  {
    label: 'Реквизиты моей компании',
    value: 'my_company_details',
    color: 'air-primary-success',
    icon: MyPlanIcon
  },
  {
    label: 'В работе',
    value: 'in_progress'
  },
  {
    label: 'Права доступа',
    value: 'access_permissions',
    color: 'air-primary-alert',
    icon: Shield2DefendedIcon
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)

const icon = computed(() => items.value.find(item => item.value === value.value)?.icon)
</script>

<template>
  <B24Select v-model="value" :icon="icon" :items="items" value-key="value" class="w-48" />
</template>

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

Свойство icon показывает иконку внутри элементов.

<script setup lang="ts">
import type { SelectItem } from '@bxshefby/b24ui-nuxt'
import SettingsIcon from '@bitrix24/b24icons-vue/main/SettingsIcon'
import MyPlanIcon from '@bitrix24/b24icons-vue/main/MyPlanIcon'
import Shield2DefendedIcon from '@bitrix24/b24icons-vue/main/Shield2DefendedIcon'

const items = ref([
  {
    label: 'Настройки CRM',
    value: 'settings',
    icon: SettingsIcon
  },
  {
    label: 'Реквизиты моей компании',
    value: 'my_company_details',
    icon: MyPlanIcon
  },
  {
    label: 'В работе',
    value: 'in_progress'
  },
  {
    label: 'Права доступа',
    value: 'access_permissions',
    icon: Shield2DefendedIcon
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)

const icon = computed(() => items.value.find(item => item.value === value.value)?.icon)
</script>

<template>
  <B24Select v-model="value" :icon="icon" :items="items" value-key="value" class="w-48" />
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import type { SelectItem } from '@bxshefby/b24ui-nuxt'
import SettingsIcon from '@bitrix24/b24icons-vue/main/SettingsIcon'
import MyPlanIcon from '@bitrix24/b24icons-vue/main/MyPlanIcon'
import Shield2DefendedIcon from '@bitrix24/b24icons-vue/main/Shield2DefendedIcon'

const items = ref([
  {
    label: 'Настройки CRM',
    value: 'settings',
    icon: SettingsIcon
  },
  {
    label: 'Реквизиты моей компании',
    value: 'my_company_details',
    icon: MyPlanIcon
  },
  {
    label: 'В работе',
    value: 'in_progress'
  },
  {
    label: 'Права доступа',
    value: 'access_permissions',
    icon: Shield2DefendedIcon
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)

const icon = computed(() => items.value.find(item => item.value === value.value)?.icon)
</script>

<template>
  <B24Select v-model="value" :icon="icon" :items="items" value-key="value" class="w-48" />
</template>
В этом примере иконка вычисляется из свойства value выбранного элемента.
Слот #leading и его проп item позволяют показать иконку выбранного элемента.

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

Свойство avatar показывает Avatar внутри элементов.

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

const items = ref([
  {
    label: 'Ассистент',
    value: 'assistant',
    avatar: {
      src: '/b24ui/avatar/assistant.png',
      alt: 'assistant',
      loading: 'lazy' as const
    }
  },
  {
    label: 'Сотрудник',
    value: 'employee',
    avatar: {
      src: '/b24ui/avatar/employee.png',
      alt: 'employee',
      loading: 'lazy' as const
    }
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)

const avatar = computed(() => items.value.find(item => item.value === value.value)?.avatar)
</script>

<template>
  <B24Select v-model="value" :items="items" value-key="value" :avatar="avatar" class="w-48" />
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import type { SelectItem } from '@bxshefby/b24ui-nuxt'

const items = ref([
  {
    label: 'Ассистент',
    value: 'assistant',
    avatar: {
      src: '/b24ui/avatar/assistant.png',
      alt: 'assistant',
      loading: 'lazy' as const
    }
  },
  {
    label: 'Сотрудник',
    value: 'employee',
    avatar: {
      src: '/b24ui/avatar/employee.png',
      alt: 'employee',
      loading: 'lazy' as const
    }
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)

const avatar = computed(() => items.value.find(item => item.value === value.value)?.avatar)
</script>

<template>
  <B24Select v-model="value" :items="items" value-key="value" :avatar="avatar" class="w-48" />
</template>
В этом примере аватар вычисляется из свойства value выбранного элемента.
Слот #leading и его проп item позволяют показать аватар выбранного элемента.

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

Свойство chip показывает Chip внутри элементов.

<script setup lang="ts">
import type { SelectItem, ChipProps } from '@bxshefby/b24ui-nuxt'

const items = ref([
  {
    label: 'Ошибка',
    value: 'bug',
    chip: {
      color: 'air-primary-alert'
    }
  },
  {
    label: 'Функция',
    value: 'feature',
    chip: {
      color: 'air-primary-success'
    }
  },
  {
    label: 'Улучшение',
    value: 'enhancement',
    chip: {
      color: 'air-primary-copilot'
    }
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)
</script>

<template>
  <B24Select v-model="value" :items="items" value-key="value" class="w-48">
    <template #leading="{ item, b24ui }">
      <B24Chip
        v-if="item"
        v-bind="item.chip"
        inset
        standalone
        :size="(b24ui.itemLeadingChipSize() as ChipProps['size'])"
        :class="b24ui.itemLeadingChip()"
      />
    </template>
  </B24Select>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { SelectItem, ChipProps } from '@bxshefby/b24ui-nuxt'

const items = ref([
  {
    label: 'Ошибка',
    value: 'bug',
    chip: {
      color: 'air-primary-alert'
    }
  },
  {
    label: 'Функция',
    value: 'feature',
    chip: {
      color: 'air-primary-success'
    }
  },
  {
    label: 'Улучшение',
    value: 'enhancement',
    chip: {
      color: 'air-primary-copilot'
    }
  }
] satisfies SelectItem[])

const value = ref(items.value[0]?.value)
</script>

<template>
  <B24Select v-model="value" :items="items" value-key="value" class="w-48">
    <template #leading="{ item, b24ui }">
      <B24Chip
        v-if="item"
        v-bind="item.chip"
        inset
        standalone
        :size="(b24ui.itemLeadingChipSize() as ChipProps['size'])"
        :class="b24ui.itemLeadingChip()"
      />
    </template>
  </B24Select>
</template>
В этом примере слот #leading берёт чип выбранного элемента из его пропа item.

Управление открытием

Состоянием открытия управляют пропс default-open или директива v-model:open.

<script setup lang="ts">
const open = ref(false)
const items = ref(['Настройки CRM', 'Реквизиты моей компании', 'Права доступа'])
const value = ref('Реквизиты моей компании')

defineShortcuts({
  o: () => open.value = !open.value
})
</script>

<template>
  <B24Select v-model="value" v-model:open="open" :items="items" class="w-48" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const open = ref(false)
const items = ref(['Настройки CRM', 'Реквизиты моей компании', 'Права доступа'])
const value = ref('Реквизиты моей компании')

defineShortcuts({
  o: () => open.value = !open.value
})
</script>

<template>
  <B24Select v-model="value" v-model:open="open" :items="items" class="w-48" />
</template>
В этом примере с помощью defineShortcuts Select переключается по нажатию O.

С вращающейся иконкой

Пример с вращающейся иконкой, которая показывает состояние открытия Select.

<script setup lang="ts">
const items = ref(['Настройки CRM', 'Реквизиты моей компании', 'Права доступа'])
const value = ref('Реквизиты моей компании')
</script>

<template>
  <B24Select
    v-model="value"
    :items="items"
    :b24ui="{
      trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200'
    }"
    class="w-48"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const items = ref(['Настройки CRM', 'Реквизиты моей компании', 'Права доступа'])
const value = ref('Реквизиты моей компании')
</script>

<template>
  <B24Select
    v-model="value"
    :items="items"
    :b24ui="{
      trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200'
    }"
    class="w-48"
  />
</template>

С загружаемыми элементами

Элементы можно загружать из API и использовать в Select.

<script setup lang="ts">
import type { AvatarProps } from '@bxshefby/b24ui-nuxt'
import UserIcon from '@bitrix24/b24icons-vue/common-b24/UserIcon'
import Expand1Icon from '@bitrix24/b24icons-vue/actions/Expand1Icon'

const { data: users, status, execute } = await useLazyFetch('https://jsonplaceholder.typicode.com/users', {
  key: 'typicode-users',
  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
})

function onOpen() {
  if (!users.value?.length) {
    execute()
  }
}
</script>

<template>
  <B24Select
    :items="users"
    :loading="status === 'pending'"
    :icon="UserIcon"
    :trailing-icon="Expand1Icon"
    placeholder="Выберите пользователя"
    value-key="value"
    class="w-48"
    @update:open="onOpen"
  >
    <template #leading="{ item, b24ui }">
      <B24Avatar
        v-if="item"
        v-bind="item.avatar"
        :size="(b24ui.leadingAvatarSize() as AvatarProps['size'])"
        :class="b24ui.leadingAvatar()"
      />
    </template>
  </B24Select>
</template>
В примере useLazyFetch вызывается с immediate: false, поэтому данные запрашиваются только при открытии меню, а лишних запросов к API при загрузке страницы нет.

С бесконечной прокруткой

Композабл useInfiniteScroll подгружает данные по мере прокрутки.

<script setup lang="ts">
import { useInfiniteScroll } from '@vueuse/core'

type User = {
  firstName: string
}

type UserResponse = {
  users: User[]
  total: number
  skip: number
  limit: number
}

const skip = ref(0)

const { data, status, execute } = await useLazyFetch(
  'https://dummyjson.com/users?limit=10&select=firstName',
  {
    key: 'select-users-infinite-scroll',
    query: { skip },
    transform: (data?: UserResponse) => {
      return data?.users.map((user) => user.firstName)
    },
    immediate: false
  }
)

const users = ref<string[]>([])

watch(data, () => {
  users.value = [...users.value, ...(data.value || [])]
})

function onOpen() {
  if (!users.value?.length) {
    execute()
  }
}

const select = useTemplateRef('select')

onMounted(() => {
  useInfiniteScroll(
    () => select.value?.viewportRef,
    () => {
      skip.value += 10
    },
    {
      canLoadMore: () => {
        return status.value !== 'pending'
      }
    }
  )
})
</script>

<template>
  <B24Select
    ref="select"
    placeholder="Выберите пользователя"
    :items="users"
    @update:open="onOpen"
  />
</template>
<script setup lang="ts">
import { ref, watch, onMounted, useTemplateRef } from 'vue'
import { useInfiniteScroll } from '@vueuse/core'

type User = {
  firstName: string
}

type UserResponse = {
  users: User[]
  total: number
  skip: number
  limit: number
}

const skip = ref(0)

const { data, status, execute } = await useLazyFetch(
  'https://dummyjson.com/users?limit=10&select=firstName',
  {
    key: 'select-users-infinite-scroll',
    query: { skip },
    transform: (data?: UserResponse) => {
      return data?.users.map((user) => user.firstName)
    },
    immediate: false
  }
)

const users = ref<string[]>([])

watch(data, () => {
  users.value = [...users.value, ...(data.value || [])]
})

function onOpen() {
  if (!users.value?.length) {
    execute()
  }
}

const select = useTemplateRef('select')

onMounted(() => {
  useInfiniteScroll(
    () => select.value?.viewportRef,
    () => {
      skip.value += 10
    },
    {
      canLoadMore: () => {
        return status.value !== 'pending'
      }
    }
  )
})
</script>

<template>
  <B24Select
    ref="select"
    placeholder="Выберите пользователя"
    :items="users"
    @update:open="onOpen"
  />
</template>
В примере useLazyFetch вызывается с immediate: false, поэтому данные загружаются только по мере прокрутки.

С содержимым на всю ширину

Чтобы содержимое занимало всю ширину своих элементов, настройте слоты b24ui.content, b24ui.item и b24ui.viewport.

<script setup lang="ts">
import UserIcon from '@bitrix24/b24icons-vue/common-b24/UserIcon'
import Expand1Icon from '@bitrix24/b24icons-vue/actions/Expand1Icon'

const value = ref<string>()

const { data: users, 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
})

function onOpen() {
  if (!users.value?.length) {
    execute()
  }
}
</script>

<template>
  <B24Select
    v-model="value"
    :items="users"
    :icon="UserIcon"
    :trailing-icon="Expand1Icon"
    placeholder="Выберите пользователя"
    value-key="value"
    :b24ui="{ content: 'min-w-fit', viewport: 'min-w-fit', item: 'min-w-fit' }"
    class="w-48"
    @update:open="onOpen"
  >
    <template #item-label="{ item }">
      {{ item.label }}

      <span class="text-description">
        {{ item.email }}
      </span>
    </template>
  </B24Select>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import UserIcon from '@bitrix24/b24icons-vue/common-b24/UserIcon'
import Expand1Icon from '@bitrix24/b24icons-vue/actions/Expand1Icon'

const value = ref<string>()

const { data: users, 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
})

function onOpen() {
  if (!users.value?.length) {
    execute()
  }
}
</script>

<template>
  <B24Select
    v-model="value"
    :items="users"
    :icon="UserIcon"
    :trailing-icon="Expand1Icon"
    placeholder="Выберите пользователя"
    value-key="value"
    :b24ui="{ content: 'min-w-fit', viewport: 'min-w-fit', item: 'min-w-fit' }"
    class="w-48"
    @update:open="onOpen"
  >
    <template #item-label="{ item }">
      {{ item.label }}

      <span class="text-description">
        {{ item.email }}
      </span>
    </template>
  </B24Select>
</template>

API

Пропсы

Prop Default Type
id string
placeholder string

The placeholder text when the select is empty.

color'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot"
size'md' "sm" | "xss" | "xs" | "md" | "lg" | "xl"
noPaddingfalseboolean

Removes padding from input

noBorderfalseboolean

Removes all borders (rings)

underlinefalseboolean

Removes all borders (rings) except the bottom one

roundedfalseboolean

Rounds the corners of the select

tag string
tagColor'air-primary'"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" | "air-selection"
trailingIconicons.chevronDownIconComponent

The icon displayed to open the menu.

selectedIconicons.checkIconComponent

The icon displayed when an item is selected.

content{ side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' } SelectContentProps & Partial<EmitsToProps<SelectContentImplEmits>>

The content of the menu.

arrowfalseboolean | SelectArrowProps

Display an arrow alongside the menu.

portaltrue string | false | true | HTMLElement

Render the menu in a portal.

valueKey'value' VK

When items is an array of objects, select the field to use as the value.

labelKey'label' keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>>

When items is an array of objects, select the field to use as the label.

descriptionKey'description' keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>>

When items is an array of objects, select the field to use as the description.

items T
defaultValue _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod>

The value of the Select when initially rendered. Use when you do not need to control the state of the Select.

modelValue _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod>

The controlled value of the Select. Can be bind as v-model.

modelModifiers Mod
multiple M

Whether multiple options can be selected or not.

highlightboolean

Highlight the ring color like a focus state.

fixedboolean

Keep the mobile text size on all breakpoints.

autofocusboolean
autofocusDelay0 number
disabledboolean

When true, prevents the user from interacting with Select

openboolean

The controlled open state of the Select. Can be bind as v-model:open.

defaultOpenboolean

The open state of the select when it is initially rendered. Use when you do not need to control its open state.

nullableValue string

The value of the hidden native select option when the model value is nullish.

autocomplete string

Native html input autocomplete attribute.

name string

The name of the field. Submitted with its owning form as part of a name/value pair.

requiredboolean

When true, indicates that the user must set the value before the owning form can be submitted.

iconIconComponent

Display an icon on the left side.

avatar AvatarProps

Display an avatar on the left side.

loadingboolean

When true, the loading icon will be displayed.

trailingboolean

When true, the icon will be displayed on the right side.

b24ui { root?: SlotClass; base?: SlotClass; leading?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailing?: SlotClass; trailingIcon?: SlotClass; tag?: SlotClass; value?: SlotClass; placeholder?: SlotClass; content?: SlotClass; viewport?: SlotClass; arrow?: SlotClass; group?: SlotClass; empty?: SlotClass; label?: SlotClass; separator?: SlotClass; item?: SlotClass; itemLeadingIcon?: SlotClass; itemLeadingAvatar?: SlotClass; itemLeadingAvatarSize?: SlotClass; itemLeadingChip?: SlotClass; itemLeadingChipSize?: SlotClass; itemTrailing?: SlotClass; itemTrailingIcon?: SlotClass; itemWrapper?: SlotClass; itemLabel?: SlotClass; itemDescription?: SlotClass; }
Компонент поддерживает и все нативные HTML-атрибуты <button>.

Слоты

Slot Type
leading{ modelValue: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod>; item: GetSelectedItem<T, M, ExcludeItem>; open: boolean; b24ui: object; }
default{ modelValue: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod>; item: GetSelectedItem<T, M, ExcludeItem>; open: boolean; b24ui: object; }
trailing{ modelValue: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod>; item: GetSelectedItem<T, M, ExcludeItem>; open: boolean; b24ui: object; }
item{ item: NestedItem<T>; index: number; b24ui: object; }
item-leading{ item: NestedItem<T>; index: number; b24ui: object; }
item-label{ item: NestedItem<T>; index: number; }
item-description{ item: NestedItem<T>; index: number; }
item-trailing{ item: NestedItem<T>; index: number; b24ui: object; }
content-top{}
content-bottom{}

События

Event Type
update:modelValue[value: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod>]
update:open[value: boolean]
change[event: Event]
blur[event: FocusEvent]
focus[event: FocusEvent]

Доступ через ref

При обращении к компоненту через ref в шаблоне доступно:

ИмяТип
triggerRefRef<HTMLButtonElement | null>
viewportRefRef<HTMLDivElement | null>

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/select.ts
export default {
  slots: {
    root: 'isolate relative inline-flex items-center',
    base: 'relative inline-flex items-center group px-3 w-full py-0 border-0 focus:outline-none cursor-pointer disabled:cursor-not-allowed disabled:pointer-events-auto disabled:select-none disabled:opacity-30 disabled:resize-none appearance-none transition-colors duration-300 ease-linear text-(--ui-color-base-1) style-blurred-bg-input hover:text-(--ui-color-base-1) focus:text-(--ui-color-base-1) active:text-(--ui-color-base-1) font-[family-name:var(--ui-font-family-primary)] font-(--ui-font-weight-regular) align-middle text-ellipsis whitespace-nowrap',
    leading: 'absolute inset-y-0 start-0 flex items-center',
    leadingIcon: 'shrink-0 text-(--b24ui-icon-color)',
    leadingAvatar: 'shrink-0',
    leadingAvatarSize: '',
    trailing: 'absolute inset-y-0 end-0 flex items-center',
    trailingIcon: 'shrink-0 text-(--b24ui-icon-color)',
    tag: 'pointer-events-none select-none absolute z-10 -top-[7px] right-[14px] flex flex-col justify-center items-center',
    value: 'truncate pointer-events-none',
    placeholder: 'truncate text-(--ui-color-design-plain-na-content-secondary)',
    content: 'base-mode flex flex-col max-h-[min(var(--max-height-popup-list),var(--reka-select-content-available-height,100vh))] bg-(--ui-color-bg-content-primary) shadow-(--popup-window-box-shadow) rounded-(--ui-border-radius-xl) will-change-[opacity] origin-(--reka-select-content-transform-origin) font-[family-name:var(--ui-font-family-primary)] relative isolate px-0 py-(--menu-popup-padding) pointer-events-auto data-[state=closed]:pointer-events-none!',
    viewport: 'relative scroll-py-1 w-60 min-w-(--reka-select-trigger-width) flex-1 overflow-x-hidden overflow-y-auto scrollbar-thin',
    arrow: 'fill-(--ui-color-bg-content-primary)',
    group: 'grid',
    empty: 'h-(--popup-window-delimiter-section-height) mt-(--menu-item-block-stack-space) 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)',
    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)',
    item: 'group w-full min-w-[195px] h-[36px] px-4.5 mt-(--menu-item-block-stack-space) relative flex flex-row rtl:flex-row-reverse items-center select-none outline-none whitespace-nowrap cursor-pointer data-disabled:cursor-not-allowed data-disabled:opacity-30 text-start text-(length:--ui-font-size-md) text-legend hover:text-label data-highlighted:not-data-disabled:text-label data-[state=open]:text-label data-[state=checked]:text-label hover:bg-(--ui-color-base-black-fixed)/3 dark:hover:bg-(--ui-color-base-black-fixed) active:bg-(--ui-color-base-black-fixed)/6 dark:active:bg-(--ui-color-base-black-fixed) data-highlighted:not-active:bg-(--ui-color-base-black-fixed)/3 dark:data-highlighted:not-active:bg-(--ui-color-base-black-fixed) data-[state=open]:bg-(--ui-color-base-black-fixed)/6 dark:data-[state=open]:bg-(--ui-color-base-black-fixed) transition-colors',
    itemLeadingIcon: 'size-[25px] shrink-0 text-(--ui-color-base-5)',
    itemLeadingAvatar: 'shrink-0 size-[16px] me-[12px]',
    itemLeadingAvatarSize: '2xs',
    itemLeadingChip: 'shrink-0 size-[16px]',
    itemLeadingChipSize: 'sm',
    itemTrailing: 'ml-auto rtl:ml-0 rtl:mr-auto inline-flex gap-1.5 items-center',
    itemTrailingIcon: 'shrink-0 size-[25px] text-(--ui-color-accent-main-primary)',
    itemWrapper: 'flex-1 flex flex-col min-w-0',
    itemLabel: 'truncate',
    itemDescription: 'truncate -mt-[6px] text-description text-(length:--ui-font-size-sm)'
  },
  variants: {
    fieldGroup: {
      horizontal: {
        root: 'group leading-none has-focus-visible:z-[1]',
        base: 'focus-visible:outline-none ring ring-inset ring-1 focus-visible:ring-2 group-not-only:group-first:rounded-e-3xl group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none group-not-only:group-first:border-e-0 group-not-only:group-not-first:border-s-0'
      },
      vertical: {
        root: 'group has-focus-visible:z-[1]',
        base: 'focus-visible:outline-none ring ring-inset ring-1 focus-visible:ring-2 group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none'
      }
    },
    noSplit: {
      false: "group-not-only:not-first:after:content-[''] group-not-only:not-first:after:absolute group-not-only:not-first:after:top-[7px] group-not-only:not-first:after:bottom-[6px] group-not-only:not-first:after:left-0 group-not-only:not-first:after:w-px group-not-only:not-first:after:bg-current/30"
    },
    size: {
      xss: {
        base: 'h-[20px] gap-1 text-(length:--ui-font-size-4xs)/[normal]',
        leading: 'px-1',
        trailing: 'px-1',
        leadingIcon: 'size-[12px]',
        leadingAvatarSize: '3xs',
        trailingIcon: 'size-[12px]'
      },
      xs: {
        base: 'h-[24px] gap-1 text-(length:--ui-font-size-xs)/[normal]',
        leading: 'px-1',
        trailing: 'px-1',
        leadingIcon: 'size-[14px]',
        leadingAvatarSize: '3xs',
        trailingIcon: 'size-[14px]'
      },
      sm: {
        base: 'h-[28px] gap-1.5 text-(length:--ui-font-size-xs)/[normal]',
        leading: 'px-1.5',
        trailing: 'px-1.5',
        leadingIcon: 'size-[16px]',
        leadingAvatar: 'size-[16px]',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-[16px]'
      },
      md: {
        base: 'h-[34px] gap-1.5 text-(length:--ui-font-size-lg)/[normal]',
        leading: 'px-2',
        trailing: 'px-2',
        leadingIcon: 'size-4.5',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-4.5'
      },
      lg: {
        base: 'h-[38px] gap-2 text-(length:--ui-font-size-lg)/[normal]',
        leading: 'px-2',
        trailing: 'px-2',
        leadingIcon: 'size-[22px]',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-[22px]'
      },
      xl: {
        base: 'h-[46px] gap-2 text-(length:--ui-font-size-2xl)/[normal]',
        leading: 'px-2',
        trailing: 'px-2',
        leadingIcon: 'size-[22px]',
        leadingAvatarSize: '2xs',
        trailingIcon: 'size-[22px]'
      }
    },
    color: {
      'air-primary': {
        base: 'style-filled'
      },
      'air-primary-success': {
        base: 'style-filled-success'
      },
      'air-primary-alert': {
        base: 'style-filled-alert'
      },
      'air-primary-copilot': {
        base: 'style-filled-copilot'
      },
      'air-primary-warning': {
        base: 'style-filled-warning'
      },
      default: {
        base: 'style-old-default'
      },
      danger: {
        base: 'style-old-danger'
      },
      success: {
        base: 'style-old-success'
      },
      warning: {
        base: 'style-old-warning'
      },
      primary: {
        base: 'style-old-primary'
      },
      secondary: {
        base: 'style-old-secondary'
      },
      collab: {
        base: 'style-old-collab'
      },
      ai: {
        base: 'style-old-ai'
      }
    },
    rounded: {
      true: 'rounded-(--ui-border-radius-3xl)',
      false: 'rounded-(--ui-border-radius-sm)'
    },
    noPadding: {
      true: {
        base: 'px-0'
      }
    },
    noBorder: {
      true: 'ring-0 focus-visible:ring-0 style-transparent-bg'
    },
    underline: {
      true: 'rounded-none ring-0 focus-visible:ring-0 style-transparent-bg border-b-1 border-b-(--ui-color-design-outline-stroke)'
    },
    leading: {
      true: ''
    },
    trailing: {
      true: ''
    },
    loading: {
      true: ''
    },
    highlight: {
      true: 'ring ring-inset ring-(--b24ui-border-color)'
    },
    fixed: {
      false: ''
    },
    type: {
      file: 'file:me-1.5 file:text-(--ui-color-design-plain-na-content-secondary) file:outline-none'
    },
    colorItem: {
      'air-primary': {
        item: 'style-filled'
      },
      'air-primary-success': {
        item: 'style-filled-success'
      },
      'air-primary-alert': {
        item: 'style-filled-alert'
      },
      'air-primary-copilot': {
        item: 'style-filled-copilot'
      },
      'air-primary-warning': {
        item: 'style-filled-warning'
      },
      default: {
        item: 'style-old-default'
      },
      danger: {
        item: 'style-old-danger'
      },
      success: {
        item: 'style-old-success'
      },
      warning: {
        item: 'style-old-warning'
      },
      primary: {
        item: 'style-old-primary'
      },
      secondary: {
        item: 'style-old-secondary'
      },
      collab: {
        item: 'style-old-collab'
      },
      ai: {
        item: 'style-old-ai'
      }
    },
    position: {
      popper: {
        content: 'motion-safe:data-[state=open]:animate-[scale-in_100ms_var(--ease-out)] motion-safe:data-[state=closed]:animate-[scale-out_100ms_var(--ease-out)]'
      },
      'item-aligned': {
        content: '',
        viewport: 'w-full'
      }
    },
    multiple: {
      true: ''
    }
  },
  compoundVariants: [
    {
      colorItem: [
        'air-primary',
        'air-primary-success',
        'air-primary-alert',
        'air-primary-copilot',
        'air-primary-warning'
      ],
      active: false,
      class: {
        item: 'text-(--b24ui-background) data-highlighted:text-(--b24ui-background-hover) data-[state=open]:text-(--b24ui-background-hover)',
        itemLeadingIcon: 'text-(--b24ui-background) group-data-highlighted:text-(--b24ui-background-hover) group-data-[state=open]:text-(--b24ui-background-hover)'
      }
    },
    {
      colorItem: [
        'air-primary',
        'air-primary-success',
        'air-primary-alert',
        'air-primary-copilot',
        'air-primary-warning'
      ],
      active: true,
      class: {
        item: 'text-(--b24ui-background-active)',
        itemLeadingIcon: 'text-(--b24ui-background-active) group-data-[state=open]:text-(--b24ui-background-active)'
      }
    },
    {
      colorItem: 'default',
      active: false,
      class: ''
    },
    {
      colorItem: 'default',
      active: true,
      class: ''
    },
    {
      colorItem: [
        'danger',
        'success',
        'warning',
        'primary',
        'secondary',
        'collab',
        'ai'
      ],
      active: false,
      class: {
        item: 'text-(--b24ui-background-active) data-highlighted:text-(--b24ui-background-hover) data-[state=open]:text-(--b24ui-background-hover)',
        itemLeadingIcon: 'text-(--b24ui-icon) group-data-highlighted:text-(--b24ui-icon) group-data-[state=open]:text-(--b24ui-icon)'
      }
    },
    {
      colorItem: [
        'danger',
        'success',
        'warning',
        'primary',
        'secondary',
        'collab',
        'ai'
      ],
      active: true,
      class: {
        item: 'text-(--b24ui-background-active)',
        itemLeadingIcon: 'text-(--b24ui-background-active) group-data-[state=open]:text-(--b24ui-background-active)'
      }
    },
    {
      highlight: false,
      noBorder: false,
      underline: false,
      class: {
        base: 'ring ring-inset ring-(--ui-color-design-outline-stroke) focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-(--b24ui-border-color) hover:not-disabled:not-data-disabled:ring-1 hover:not-disabled:not-data-disabled:ring-inset hover:not-disabled:not-data-disabled:ring-(--b24ui-border-color) data-[state=open]:ring-1 data-[state=open]:ring-inset data-[state=open]:ring-(--b24ui-border-color)'
      }
    },
    {
      highlight: true,
      noBorder: false,
      underline: false,
      class: {
        base: 'ring ring-inset ring-(--b24ui-border-color) focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-(--b24ui-border-color) hover:ring-1 hover:ring-inset hover:ring-(--b24ui-border-color) data-[state=open]:ring-1 data-[state=open]:ring-inset data-[state=open]:ring-(--b24ui-border-color)'
      }
    },
    {
      noBorder: false,
      underline: true,
      class: {
        base: 'focus-visible:border-(--b24ui-border-color) hover:not-disabled:not-data-disabled:border-(--b24ui-border-color) data-[state=open]:border-(--b24ui-border-color)'
      }
    },
    {
      highlight: true,
      noBorder: false,
      underline: true,
      class: {
        base: 'ring-0 border-b-(--b24ui-border-color)'
      }
    },
    {
      highlight: true,
      noBorder: true,
      underline: false,
      class: {
        base: 'ring-0'
      }
    },
    {
      type: 'file',
      size: 'xss',
      class: 'py-[2px]'
    },
    {
      type: 'file',
      size: 'xs',
      class: 'py-[4px]'
    },
    {
      type: 'file',
      size: 'sm',
      class: 'py-[5px]'
    },
    {
      type: 'file',
      size: 'md',
      class: 'py-[7px]'
    },
    {
      type: 'file',
      size: 'lg',
      class: 'py-[9px]'
    },
    {
      type: 'file',
      size: 'xl',
      class: 'py-[11px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'xss',
      class: 'ps-[20px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'xs',
      class: 'ps-[22px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'sm',
      class: 'ps-[28px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'md',
      class: 'ps-[32px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'lg',
      class: 'ps-[32px]'
    },
    {
      leading: true,
      noPadding: false,
      size: 'xl',
      class: 'ps-[32px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'xss',
      class: 'pe-[20px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'xs',
      class: 'pe-[22px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'sm',
      class: 'pe-[28px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'md',
      class: 'pe-[34px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'lg',
      class: 'pe-[38px]'
    },
    {
      trailing: true,
      noPadding: false,
      size: 'xl',
      class: 'pe-[38px]'
    },
    {
      loading: true,
      leading: true,
      class: {
        leadingIcon: 'size-[21px]'
      }
    },
    {
      loading: true,
      leading: false,
      trailing: true,
      class: {
        trailingIcon: 'size-[21px]'
      }
    },
    {
      loading: true,
      leading: true,
      noPadding: true,
      class: {
        base: 'ps-[34px]'
      }
    },
    {
      loading: true,
      leading: false,
      trailing: true,
      noPadding: true,
      class: {
        base: 'pe-[34px]'
      }
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: [
        'xl',
        'lg',
        'md'
      ],
      rounded: false,
      class: 'rounded-(--ui-border-radius-md)'
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: 'sm',
      rounded: false,
      class: 'rounded-(--ui-border-radius-sm)'
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: 'xs',
      rounded: false,
      class: 'rounded-(--ui-border-radius-xs)'
    },
    {
      fieldGroup: [
        'horizontal',
        'vertical'
      ],
      size: 'xss',
      rounded: false,
      class: 'rounded-[5px]'
    },
    {
      fixed: false,
      size: 'xss',
      class: 'md:text-(length:--ui-font-size-4xs)/[normal]'
    },
    {
      fixed: false,
      size: 'xs',
      class: 'md:text-(length:--ui-font-size-xs)/[normal]'
    },
    {
      fixed: false,
      size: 'sm',
      class: 'md:text-(length:--ui-font-size-sm)/[normal]'
    },
    {
      fixed: false,
      size: 'md',
      class: 'md:text-(length:--ui-font-size-lg)/[normal]'
    },
    {
      fixed: false,
      size: 'lg',
      class: 'md:text-(length:--ui-font-size-lg)/[normal]'
    }
  ],
  defaultVariants: {
    color: 'air-primary',
    size: 'md',
    position: 'popper'
  }
}