SelectMenu
검색 기능을 갖춘 고급 Select 컴포넌트예요. 문자열·숫자·객체 아이템, 다중 선택, 생성 아이템, 가상화, 무한 스크롤까지 폭넓게 지원해요.
출처: Nuxt UI
본문
고급 검색 가능한 select 요소예요.
사용법
v-model 디렉티브로 SelectMenu의 값을 제어하거나, 상태를 제어할 필요가 없을 때 default-value prop으로 초기 값을 설정할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" :items="items" />
</template>
[!TIP]
Select보다 이 컴포넌트를 사용하면 검색 기능과 다중 선택을 제공하는 Reka UI의Combobox컴포넌트를 활용할 수 있어요.
[!NOTE]
이 컴포넌트는
InputMenu와 비슷하지만, 메뉴 안에 검색을 둔 Input 대신 Select를 사용해요.
아이템 (Items)
items prop을 문자열, 숫자, 부울 배열로 사용할 수 있어요:
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" :items="items" class="w-48" />
</template>
다음 속성을 가진 객체 배열도 전달할 수 있어요:
label?: stringtype?: "label" | "separator" | "item"icon?: stringavatar?: AvatarPropschip?: ChipPropsdisabled?: booleanonSelect?: (e: Event) => voidclass?: anyui?: { label?: ClassNameValue, separator?: ClassNameValue, item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingAvatarSize?: ClassNameValue, itemLeadingAvatar?: ClassNameValue, itemLeadingChipSize?: ClassNameValue, itemLeadingChip?: ClassNameValue, itemLabel?: ClassNameValue, itemTrailing?: ClassNameValue, itemTrailingIcon?: ClassNameValue }
<script setup lang="ts">
import type { SelectMenuItem } from '@nuxt/ui'
const items = ref<SelectMenuItem[]>([
{
label: "Backlog"
},
{
label: "Todo"
},
{
label: "In Progress"
},
{
label: "Done"
}
])
const value = ref({
label: "Todo"
})
</script>
<template>
<USelectMenu v-model="value" :items="items" class="w-48" />
</template>
[!CAUTION]
Select컴포넌트와 달리 SelectMenu는 기본적으로v-model디렉티브나default-valueprop에 전체 객체를 전달할 것을 기대해요.
items prop에 배열의 배열을 전달해서 분리된 그룹의 아이템을 표시할 수도 있어요.
<script setup lang="ts">
const items = ref([
[
"Apple",
"Banana",
"Blueberry",
"Grapes",
"Pineapple"
],
[
"Aubergine",
"Broccoli",
"Carrot",
"Courgette",
"Leek"
]
])
const value = ref("Apple")
</script>
<template>
<USelectMenu v-model="value" :items="items" class="w-48" />
</template>
값 키 (Value Key)
value-key prop으로 전체 객체 대신 객체의 단일 속성을 바인딩하도록 선택할 수 있어요. 기본값은 undefined예요.
<script setup lang="ts">
import type { SelectMenuItem } from '@nuxt/ui'
const items = ref<SelectMenuItem[]>([
{
label: "Backlog",
id: "backlog"
},
{
label: "Todo",
id: "todo"
},
{
label: "In Progress",
id: "in_progress"
},
{
label: "Done",
id: "done"
}
])
const value = ref("todo")
</script>
<template>
<USelectMenu v-model="value" value-key="id" :items="items" class="w-48" />
</template>
[!TIP]
model-value가 객체일 때 참조(reference) 대신 필드로 객체를 비교하려면byprop을 사용하면 돼요.
다중 선택 (Multiple)
multiple prop으로 다중 선택을 허용할 수 있어요. 선택된 항목은 트리거에서 쉼표로 구분돼요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref([
"Backlog",
"Todo"
])
</script>
<template>
<USelectMenu v-model="value" multiple :items="items" class="w-48" />
</template>
[!CAUTION]
default-valueprop이나v-model디렉티브에 배열을 전달해야 해요.
플레이스홀더 (Placeholder)
placeholder prop으로 플레이스홀더 텍스트를 설정할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
</script>
<template>
<USelectMenu placeholder="Select status" :items="items" class="w-48" />
</template>
검색 입력 (Search Input)
search-input prop으로 검색 입력을 커스터마이징하거나(false 값으로) 숨길 수 있어요.
Input 컴포넌트의 어떤 속성이든 전달해서 커스터마이징할 수 있어요.
<script setup lang="ts">
import type { SelectMenuItem } from '@nuxt/ui'
const items = ref<SelectMenuItem[]>([
{
label: "Backlog",
icon: "i-lucide-circle-help"
},
{
label: "Todo",
icon: "i-lucide-circle-plus"
},
{
label: "In Progress",
icon: "i-lucide-circle-arrow-up"
},
{
label: "Done",
icon: "i-lucide-circle-check"
}
])
const value = ref({
label: "Backlog",
icon: "i-lucide-circle-help"
})
</script>
<template>
<USelectMenu v-model="value" :search-input="{
placeholder: 'Filter...',
icon: 'i-lucide-search'
}" :items="items" class="w-48" />
</template>
[!TIP]
search-inputprop을false로 설정해서 검색 입력을 숨길 수 있어요.
[!NOTE]
:search-input="{ autofocus: false }"를 사용하면 메뉴가 열릴 때 검색 입력이 포커스되지 않아요. 예를 들어 터치 기기에서 가상 키보드가 열리는 것을 피하려면요.
콘텐츠 (Content)
content prop으로 SelectMenu 콘텐츠가 렌더링되는 방식을 제어할 수 있어요. 예를 들어 align이나 side 같은 것이요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" :content="{
align: 'center',
side: 'bottom',
sideOffset: 8
}" :items="items" class="w-48" />
</template>
화살표 (Arrow)
arrow prop으로 SelectMenu에 화살표를 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" arrow :items="items" class="w-48" />
</template>
색상 (Color)
color prop으로 SelectMenu가 포커스될 때 링(ring) 색상을 바꿀 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" color="neutral" highlight :items="items" class="w-48" />
</template>
[!NOTE]
여기서
highlightprop은 포커스 상태를 보여주기 위해 사용돼요. 검증 오류가 발생하면 내부적으로 사용됩니다.
변형 (Variant)
variant prop으로 SelectMenu의 변형을 바꿀 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" color="neutral" variant="subtle" :highlight="false" :items="items" class="w-48" />
</template>
크기 (Size)
size prop으로 SelectMenu의 크기를 바꿀 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" size="xl" :items="items" class="w-48" />
</template>
아이콘 (Icon)
icon prop으로 SelectMenu 안에 Icon을 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" icon="i-lucide-search" size="md" :items="items" class="w-48" />
</template>
트레일링 아이콘 (Trailing Icon)
trailing-icon prop으로 트레일링 Icon을 커스터마이징할 수 있어요. 기본값은 i-lucide-chevron-down이에요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" trailing-icon="i-lucide-arrow-down" size="md" :items="items" class="w-48" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
You can customize this icon globally in your
app.config.tsunderui.icons.chevronDownkey.
app.config.ts의 ui.icons.chevronDown 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
You can customize this icon globally in your
vite.config.tsunderui.icons.chevronDownkey.
vite.config.ts의 ui.icons.chevronDown 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
선택 아이콘 (Selected Icon)
selected-icon prop으로 항목이 선택되었을 때 아이콘을 커스터마이징할 수 있어요. 기본값은 i-lucide-check예요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" selected-icon="i-lucide-flame" size="md" :items="items" class="w-48" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
You can customize this icon globally in your
app.config.tsunderui.icons.checkkey.
app.config.ts의 ui.icons.check 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
You can customize this icon globally in your
vite.config.tsunderui.icons.checkkey.
vite.config.ts의 ui.icons.check 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
정리 (Clear) 4.4+
clear prop으로 값이 선택되었을 때 정리 버튼을 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" clear :items="items" class="w-48" />
</template>
정리 아이콘 (Clear Icon) 4.4+
clear-icon prop으로 정리 버튼 Icon을 커스터마이징할 수 있어요. 기본값은 i-lucide-x예요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" clear clear-icon="i-lucide-trash" :items="items" class="w-48" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
You can customize this icon globally in your
app.config.tsunderui.icons.closekey.
app.config.ts의 ui.icons.close 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
You can customize this icon globally in your
vite.config.tsunderui.icons.closekey.
vite.config.ts의 ui.icons.close 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
아바타 (Avatar)
avatar prop으로 SelectMenu 안에 Avatar를 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Nuxt",
"NuxtHub",
"NuxtLabs",
"Nuxt Modules",
"Nuxt Community"
])
const value = ref("Nuxt")
</script>
<template>
<USelectMenu v-model="value" :avatar="{
src: 'https://github.com/nuxt.png',
loading: 'lazy'
}" :items="items" class="w-48" />
</template>
로딩 (Loading)
loading prop으로 SelectMenu에 로딩 아이콘을 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" loading :trailing="false" :items="items" class="w-48" />
</template>
로딩 아이콘 (Loading Icon)
loading-icon prop으로 로딩 아이콘을 커스터마이징할 수 있어요. 기본값은 i-lucide-loader-circle이에요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<USelectMenu v-model="value" loading loading-icon="i-lucide-loader" :items="items" class="w-48" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
You can customize this icon globally in your
app.config.tsunderui.icons.loadingkey.
app.config.ts의 ui.icons.loading 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
You can customize this icon globally in your
vite.config.tsunderui.icons.loadingkey.
vite.config.ts의 ui.icons.loading 키에서 이 아이콘을 전역으로 커스터마이징할 수 있어요.
비활성화 (Disabled)
disabled prop으로 SelectMenu를 비활성화할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
</script>
<template>
<USelectMenu disabled placeholder="Select status" :items="items" class="w-48" />
</template>
예시 (Examples)
아이템 타입으로 (With items type)
type 속성을 separator와 함께 사용하면 아이템 사이에 구분자를, label과 함께 사용하면 라벨을 표시할 수 있어요.
<script setup lang="ts">
import type { SelectMenuItem } from '@nuxt/ui'
const items = ref<SelectMenuItem[]>([
[
{
type: "label",
label: "Fruits"
},
"Apple",
"Banana",
"Blueberry",
"Grapes",
"Pineapple"
],
[
{
type: "label",
label: "Vegetables"
},
"Aubergine",
"Broccoli",
"Carrot",
"Courgette",
"Leek"
]
])
const value = ref("Apple")
</script>
<template>
<USelectMenu v-model="value" :items="items" class="w-48" />
</template>
[!NOTE]
label아이템을 그룹 제목으로 사용할 때는 배열의 배열을 전달해서, 검색할 때 라벨이 그 그룹과 함께 필터링되도록 하세요.
아이템에 아이콘으로 (With icon in items)
icon 속성으로 아이템 안에 Icon을 표시할 수 있어요.
<script setup lang="ts">
import type { SelectMenuItem } from '@nuxt/ui'
const items = ref([
{
label: 'Backlog',
value: 'backlog',
icon: 'i-lucide-circle-help'
},
{
label: 'Todo',
value: 'todo',
icon: 'i-lucide-circle-plus'
},
{
label: 'In Progress',
value: 'in_progress',
icon: 'i-lucide-circle-arrow-up'
},
{
label: 'Done',
value: 'done',
icon: 'i-lucide-circle-check'
}
] satisfies SelectMenuItem[])
const value = ref(items.value[0])
</script>
<template>
<USelectMenu v-model="value" :icon="value?.icon" :items="items" class="w-48" />
</template>
[!TIP]
선택된 아이콘을 표시하려면
#leading슬롯도 사용할 수 있어요.
아이템에 아바타로 (With avatar in items)
avatar 속성으로 아이템 안에 Avatar를 표시할 수 있어요.
<script setup lang="ts">
import type { SelectMenuItem } from '@nuxt/ui'
const items = ref([
{
label: 'benjamincanac',
value: 'benjamincanac',
avatar: {
src: 'https://github.com/benjamincanac.png',
alt: 'benjamincanac',
loading: 'lazy' as const
}
},
{
label: 'HugoRCD',
value: 'HugoRCD',
avatar: {
src: 'https://github.com/HugoRCD.png',
alt: 'HugoRCD',
loading: 'lazy' as const
}
},
{
label: 'atinux',
value: 'atinux',
avatar: {
src: 'https://github.com/atinux.png',
alt: 'atinux',
loading: 'lazy' as const
}
},
{
label: 'romhml',
value: 'romhml',
avatar: {
src: 'https://github.com/romhml.png',
alt: 'romhml',
loading: 'lazy' as const
}
}
] satisfies SelectMenuItem[])
const value = ref(items.value[0])
</script>
<template>
<USelectMenu v-model="value" :avatar="value?.avatar" :items="items" class="w-48" />
</template>
[!TIP]
선택된 아바타를 표시하려면
#leading슬롯도 사용할 수 있어요.
아이템에 칩으로 (With chip in items)
chip 속성으로 아이템 안에 Chip을 표시할 수 있어요.
<script setup lang="ts">
import type { SelectMenuItem, ChipProps } from '@nuxt/ui'
const items = ref([
{
label: 'bug',
value: 'bug',
chip: {
color: 'error'
}
},
{
label: 'feature',
value: 'feature',
chip: {
color: 'success'
}
},
{
label: 'enhancement',
value: 'enhancement',
chip: {
color: 'info'
}
}
] satisfies SelectMenuItem[])
const value = ref(items.value[0])
</script>
<template>
<USelectMenu v-model="value" :items="items" class="w-48">
<template #leading="{ modelValue, ui }">
<UChip
v-if="modelValue"
v-bind="modelValue.chip"
inset
standalone
:size="(ui.itemLeadingChipSize() as ChipProps['size'])"
:class="ui.itemLeadingChip()"
/>
</template>
</USelectMenu>
</template>
[!NOTE]
이 예시에서는
#leading슬롯이 선택된 칩을 표시하는 데 사용돼요.
열린 상태 제어 (Control open state)
default-open prop이나 v-model:open 디렉티브로 열린 상태를 제어할 수 있어요.
<script setup lang="ts">
const open = ref(false)
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
defineShortcuts({
o: () => open.value = !open.value
})
</script>
<template>
<USelectMenu v-model="value" v-model:open="open" :items="items" class="w-48" />
</template>
[!NOTE]
이 예시에서는
defineShortcuts를 활용해서O키를 눌러 SelectMenu를 토글할 수 있어요.
검색어 제어 (Control search term)
v-model:search-term 디렉티브로 검색어를 제어할 수 있어요.
<script setup lang="ts">
const searchTerm = ref('D')
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>
<template>
<USelectMenu v-model="value" v-model:search-term="searchTerm" :items="items" class="w-48" />
</template>
회전 아이콘으로 (With rotating icon)
SelectMenu의 열린 상태를 나타내는 회전 아이콘 예시를 볼게요.
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>
<template>
<USelectMenu
v-model="value"
:items="items"
:ui="{
trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200'
}"
class="w-48"
/>
</template>
아이템 생성으로 (With create item)
create-item prop으로 미리 정의된 옵션에 없는 커스텀 값을 사용자가 추가할 수 있게 할 수 있어요.
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
function onCreate(item: string) {
items.value.push(item)
value.value = item
}
</script>
<template>
<USelectMenu
v-model="value"
create-item
:items="items"
class="w-48"
@create="onCreate"
/>
</template>
[!NOTE]
생성 옵션은 기본적으로 일치하는 값이 없을 때 표시돼요. 비슷한 값이 있어도 항상 표시하려면
always로 설정하면 돼요.
[!TIP] See: #emits
아이템 생성을 처리하려면
@create이벤트를 사용하면 돼요. 이벤트와 아이템을 인자로 받게 됩니다.
가져온 아이템으로 (With fetched items)
API에서 아이템을 가져와서 SelectMenu에서 사용할 수 있어요.
<script setup lang="ts">
import type { AvatarProps } from '@nuxt/ui'
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>
<USelectMenu
:items="users"
:loading="status === 'pending'"
icon="i-lucide-user"
placeholder="Select user"
class="w-48"
@update:open="onOpen"
>
<template #leading="{ modelValue, ui }">
<UAvatar
v-if="modelValue"
v-bind="modelValue.avatar"
:size="(ui.leadingAvatarSize() as AvatarProps['size'])"
:class="ui.leadingAvatar()"
/>
</template>
</USelectMenu>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해서 메뉴가 열릴 때만 데이터를 가져와 페이지 로드 시 불필요한 API 호출을 피해요.
필터 무시로 (With ignore filter)
ignore-filter prop을 true로 설정하면 내부 검색을 비활성화하고 자신만의 검색 로직을 사용할 수 있어요.
<script setup lang="ts">
import { refDebounced } from '@vueuse/core'
import type { AvatarProps } from '@nuxt/ui'
const searchTerm = ref('')
const searchTermDebounced = refDebounced(searchTerm, 200)
const { data: users, status, execute } = await useLazyFetch('https://jsonplaceholder.typicode.com/users', {
key: 'select-menu-users-search',
params: { 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
})
function onOpen() {
if (!users.value?.length) {
execute()
}
}
</script>
<template>
<USelectMenu
v-model:search-term="searchTerm"
:items="users"
:search-input="{
icon: 'i-lucide-search',
loading: status === 'pending'
}"
ignore-filter
icon="i-lucide-user"
placeholder="Select user"
class="w-48"
@update:open="onOpen"
>
<template #leading="{ modelValue, ui }">
<UAvatar
v-if="modelValue"
v-bind="modelValue.avatar"
:size="(ui.leadingAvatarSize() as AvatarProps['size'])"
:class="ui.leadingAvatar()"
/>
</template>
</USelectMenu>
</template>
[!NOTE]
이 예시는
refDebounced로 API 호출을 디바운스해요.immediate: false로 fetch가 지연되므로 메뉴가 열릴 때까지 요청이 만들어지지 않아요.
필터 필드로 (With filter fields)
filter-fields prop을 필터링할 필드 배열과 함께 사용할 수 있어요. 기본값은 [labelKey]예요.
<script setup lang="ts">
import type { AvatarProps } from '@nuxt/ui'
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
})
function onOpen() {
if (!users.value?.length) {
execute()
}
}
</script>
<template>
<USelectMenu
:items="users"
:loading="status === 'pending'"
:filter-fields="['label', 'email']"
icon="i-lucide-user"
placeholder="Select user"
class="w-80"
@update:open="onOpen"
>
<template #leading="{ modelValue, ui }">
<UAvatar
v-if="modelValue"
v-bind="modelValue.avatar"
:size="(ui.leadingAvatarSize() as AvatarProps['size'])"
:class="ui.leadingAvatar()"
/>
</template>
<template #item-label="{ item }">
{{ item.label }}
<span class="text-muted">
{{ item.email }}
</span>
</template>
</USelectMenu>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해서 메뉴가 열릴 때만 데이터를 가져와 페이지 로드 시 불필요한 API 호출을 피해요.
가상화로 (With virtualization) 4.1+
virtualize prop으로 큰 목록의 가상화를 부울값이나 { estimateSize: 32, overscan: 12 } 같은 옵션 객체로 활성화할 수 있어요.
[!WARNING] See: https://github.com/unovue/reka-ui/issues/1885
When enabled, all groups are flattened into a single list due to a limitation of Reka UI.
활성화하면 Reka UI의 제약 때문에 모든 그룹이 단일 목록으로 펼쳐져요.
<script setup lang="ts">
import type { SelectMenuItem } from '@nuxt/ui'
const items: SelectMenuItem[] = Array(1000).fill(0).map((_, i) => ({
label: `item-${i}`,
value: i
}))
</script>
<template>
<USelectMenu virtualize :items="items" class="w-48" />
</template>
무한 스크롤로 (With infinite scroll) 4.4+
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-menu-users-infinite-scroll',
params: { 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 selectMenu = useTemplateRef('selectMenu')
onMounted(() => {
useInfiniteScroll(() => selectMenu.value?.viewportRef, () => {
skip.value += 10
}, {
canLoadMore: () => {
return status.value !== 'pending'
}
})
})
</script>
<template>
<USelectMenu
ref="selectMenu"
placeholder="Select user"
:items="users"
@update:open="onOpen"
/>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해서 사용자가 스크롤할 때만 데이터가 로드돼요.
콘텐츠 전체 너비로 (With full content width)
ui.content 슬롯에 min-w-fit 클래스를 추가해서 콘텐츠를 아이템 전체 너비로 확장할 수 있어요.
<script setup lang="ts">
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>
<USelectMenu
:items="users"
icon="i-lucide-user"
placeholder="Select user"
:ui="{ content: 'min-w-fit' }"
class="w-48"
@update:open="onOpen"
>
<template #item-label="{ item }">
{{ item.label }}
<span class="text-muted">
{{ item.email }}
</span>
</template>
</USelectMenu>
</template>
[!TIP]
You can also change the content width globally in your
app.config.ts:export default defineAppConfig({ ui: { selectMenu: { slots: { content: 'min-w-fit' } } } })
콘텐츠 너비는 app.config.ts에서 전역으로도 바꿀 수 있어요.
국가 피커로 (As a country picker)
SelectMenu를 lazy loading이 있는 국가 피커로 사용할 수 있어요. 국가는 메뉴가 처음 열릴 때만 가져와요.
<script setup lang="ts">
const { data: countries, status, execute } = await useLazyFetch<{
name: string
code: string
emoji: string
}[]>('/api/countries.json', {
key: 'api-countries',
immediate: false
})
function onOpen() {
if (!countries.value?.length) {
execute()
}
}
</script>
<template>
<USelectMenu
:items="countries"
:loading="status === 'pending'"
label-key="name"
:search-input="{ icon: 'i-lucide-search' }"
placeholder="Select country"
class="w-48"
@update:open="onOpen"
>
<template #leading="{ modelValue, ui }">
<span v-if="modelValue" class="size-5 text-center">
{{ modelValue?.emoji }}
</span>
<UIcon v-else name="i-lucide-earth" :class="ui.leadingIcon()" />
</template>
<template #item-leading="{ item }">
<span class="size-5 text-center">
{{ item.emoji }}
</span>
</template>
</USelectMenu>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해서 메뉴가 처음 열릴 때만 국가를 불러와요.
API
Props
/**
* Props for the SelectMenu component
*/
interface SelectMenuProps {
id?: string | undefined;
/**
* The placeholder text when the select is empty.
*/
placeholder?: string | undefined;
/**
* Whether to display the search input or not.
* Can be an object to pass additional props to the input.
* `{ placeholder: 'Search...', variant: 'none' }`{lang="ts-type"}
* Set `autofocus: false` to prevent the search input from being focused when the menu opens (e.g. to avoid opening the virtual keyboard on touch devices).
* @default true
*/
searchInput?: boolean | Omit<InputProps<AcceptableValue, ModelModifiers>, "modelValue" | "defaultValue"> | undefined;
/**
* @default 'primary'
*/
color?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
/**
* @default 'outline'
*/
variant?: "outline" | "soft" | "subtle" | "ghost" | "none" | undefined;
/**
* @default 'md'
*/
size?: "sm" | "md" | "xs" | "lg" | "xl" | undefined;
required?: boolean | undefined;
/**
* The icon displayed to open the menu.
* @default appConfig.ui.icons.chevronDown
*/
trailingIcon?: any;
/**
* The icon displayed when an item is selected.
* @default appConfig.ui.icons.check
*/
selectedIcon?: any;
/**
* Display a clear button to reset the model value.
* Can be an object to pass additional props to the Button.
* @default false
*/
clear?: C & false | C & true | C & Partial<Omit<ButtonProps, LinkPropsKeys>> | undefined;
/**
* The icon displayed in the clear button.
* @default appConfig.ui.icons.close
*/
clearIcon?: any;
/**
* The content of the menu.
* @default { side: 'bottom', sideOffset: 8, collisionPadding: 8, position: 'popper' }
*/
content?: Omit<ComboboxContentProps, "asChild" | "as" | "forceMount"> & Partial<EmitsToProps<DismissableLayerEmits>> | undefined;
/**
* Display an arrow alongside the menu.
* `{ rounded: true }`{lang="ts-type"}
* @default false
*/
arrow?: boolean | Omit<ComboboxArrowProps, "asChild" | "as"> | undefined;
/**
* Render the menu in a portal.
* @default true
*/
portal?: string | false | true | HTMLElement | undefined;
/**
* Enable virtualization for large lists.
* Note: when enabled, all groups are flattened into a single list due to a limitation of Reka UI (https://github.com/unovue/reka-ui/issues/1885).
* @default false
*/
virtualize?: boolean | { overscan?: number | undefined; estimateSize?: number | ((index: number) => number) | undefined; } | 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;
/**
* When `items` is an array of objects, select the field to use as the label.
* @default 'label'
*/
labelKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
/**
* When `items` is an array of objects, select the field to use as the description.
* @default 'description'
*/
descriptionKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
items?: T | undefined;
/**
* The value of the SelectMenu when initially rendered. Use when you do not need to control the state of the SelectMenu.
*/
defaultValue?: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod> | IsClearUsed<M, C> | undefined;
/**
* The controlled value of the SelectMenu. Can be binded-with with `v-model`.
*/
modelValue?: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod> | IsClearUsed<M, C> | undefined;
modelModifiers?: Mod | undefined;
/**
* Whether multiple options can be selected or not.
*/
multiple?: M | undefined;
/**
* Highlight the ring color like a focus state.
*/
highlight?: boolean | undefined;
/**
* Keep the mobile text size on all breakpoints.
*/
fixed?: boolean | undefined;
/**
* Determines if custom user input that does not exist in options can be added.
* @default false
*/
createItem?: boolean | "always" | { position?: "top" | "bottom" | undefined; when?: "empty" | "always" | undefined; } | undefined;
/**
* Fields to filter items by.
* @default [labelKey]
*/
filterFields?: string[] | undefined;
/**
* When `true`, disable the default filters, useful for custom filtering (useAsyncData, useFetch, etc.).
* @default false
*/
ignoreFilter?: boolean | undefined;
autofocus?: boolean | undefined;
/**
* @default 0
*/
autofocusDelay?: number | undefined;
ui?: { base?: SlotClass; leading?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailing?: SlotClass; trailingIcon?: SlotClass; value?: SlotClass; placeholder?: SlotClass; arrow?: SlotClass; content?: SlotClass; viewport?: 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; input?: SlotClass; focusScope?: SlotClass; trailingClear?: SlotClass; } | undefined;
/**
* When `true`, prevents the user from interacting with listbox
*/
disabled?: boolean | undefined;
/**
* The controlled open state of the Combobox. Can be binded with `v-model:open`.
*/
open?: boolean | undefined;
/**
* The open state of the combobox when it is initially rendered. <br> Use when you do not need to control its open state.
*/
defaultOpen?: boolean | undefined;
/**
* The name of the field. Submitted with its owning form as part of a name/value pair.
*/
name?: string | undefined;
/**
* Whether to reset the searchTerm when the Combobox input blurred
* @default true
*/
resetSearchTermOnBlur?: boolean | undefined;
/**
* Whether to reset the searchTerm when the Combobox value is selected
* @default true
*/
resetSearchTermOnSelect?: boolean | undefined;
/**
* When `true` the `modelValue` will be reset to `null` (or `[]` if `multiple`)
* @default true
*/
resetModelValueOnClear?: boolean | undefined;
/**
* When `true`, hover over item will trigger highlight
*/
highlightOnHover?: boolean | 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: T, b: T): boolean | undefined;
/**
* Display an icon based on the `leading` and `trailing` props.
*/
icon?: any;
/**
* Display an avatar on the left side.
*/
avatar?: AvatarProps | undefined;
/**
* When `true`, the icon will be displayed on the left side.
*/
leading?: boolean | undefined;
/**
* Display an icon on the left side.
*/
leadingIcon?: any;
/**
* When `true`, the icon will be displayed on the right side.
*/
trailing?: boolean | undefined;
/**
* When `true`, the loading icon will be displayed.
*/
loading?: boolean | undefined;
/**
* The icon when the `loading` prop is `true`.
* @default appConfig.ui.icons.loading
*/
loadingIcon?: any;
form?: string | undefined;
formaction?: string | undefined;
formenctype?: string | undefined;
formmethod?: string | undefined;
formnovalidate?: false | true | "true" | "false" | undefined;
formtarget?: string | undefined;
/**
* @default ''
*/
searchTerm?: string | undefined;
}
[!NOTE] See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attributes
This component also supports all native
<button>HTML attributes.
이 컴포넌트는 모든 네이티브 <button> HTML 속성도 지원해요.
Slots
/**
* Slots for the SelectMenu component
*/
interface SelectMenuSlots {
leading(): any;
default(): any;
trailing(): any;
empty(): any;
item(): any;
item-leading(): any;
item-label(): any;
item-description(): any;
item-trailing(): any;
content-top(): any;
content-bottom(): any;
create-item-label(): any;
}
Emits
/**
* Emitted events for the SelectMenu component
*/
interface SelectMenuEmits {
update:open: (payload: [value: boolean]) => void;
change: (payload: [event: Event]) => void;
blur: (payload: [event: FocusEvent]) => void;
focus: (payload: [event: FocusEvent]) => void;
create: (payload: [item: string]) => void;
clear: (payload: []) => void;
highlight: (payload: [payload: { ref: HTMLElement; value: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod> | IsClearUsed<M, C>; } | undefined]) => void;
update:modelValue: (payload: [value: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod> | IsClearUsed<M, C>]) => void;
update:searchTerm: (payload: [value: string]) => void;
}
Expose
템플릿 ref로 컴포넌트에 접근하면 다음을 사용할 수 있어요:
| Name | Type |
|---|---|
triggerRef |
Ref<HTMLButtonElement | null> |
viewportRef |
Ref<HTMLDivElement | null> |
테마 (Theme)
export default defineAppConfig({
ui: {
selectMenu: {
slots: {
base: [
'relative group rounded-md inline-flex items-center disabled:cursor-not-allowed disabled:opacity-75',
'transition-colors'
],
leading: 'absolute inset-y-0 start-0 flex items-center',
leadingIcon: 'shrink-0 text-dimmed',
leadingAvatar: 'shrink-0',
leadingAvatarSize: '',
trailing: 'absolute inset-y-0 end-0 flex items-center',
trailingIcon: 'shrink-0 text-dimmed',
value: 'truncate pointer-events-none',
placeholder: 'truncate text-dimmed',
arrow: 'fill-bg stroke-default',
content: [
'max-h-[min(15rem,var(--reka-select-content-available-height,15rem))] w-(--reka-select-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden origin-(--reka-select-content-transform-origin) pointer-events-auto data-[state=closed]:pointer-events-none! flex flex-col',
'max-h-[min(15rem,var(--reka-combobox-content-available-height,15rem))] origin-(--reka-combobox-content-transform-origin) w-(--reka-combobox-trigger-width)'
],
viewport: 'relative scroll-py-1 overflow-y-auto flex-1',
group: 'p-1 isolate',
empty: 'text-center text-muted',
label: 'font-semibold text-highlighted',
separator: '-mx-1 my-1 h-px bg-border',
item: [
'group relative w-full flex items-start select-none outline-none before:absolute before:z-[-1] before:inset-px before:rounded-md data-disabled:cursor-not-allowed data-disabled:opacity-75 text-default data-highlighted:not-data-disabled:text-highlighted data-highlighted:not-data-disabled:before:bg-elevated/50',
'transition-colors before:transition-colors'
],
itemLeadingIcon: [
'shrink-0 text-dimmed group-data-highlighted:not-group-data-disabled:text-default',
'transition-colors'
],
itemLeadingAvatar: 'shrink-0',
itemLeadingAvatarSize: '',
itemLeadingChip: 'shrink-0',
itemLeadingChipSize: '',
itemTrailing: 'ms-auto inline-flex gap-1.5 items-center',
itemTrailingIcon: 'shrink-0',
itemWrapper: 'flex-1 flex flex-col min-w-0',
itemLabel: 'truncate',
itemDescription: 'truncate text-muted',
input: 'border-b border-default',
focusScope: 'flex flex-col min-h-0',
trailingClear: 'p-0'
},
variants: {
fieldGroup: {
horizontal: 'not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]',
vertical: 'not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]'
},
size: {
xs: {
base: 'px-2 py-1 text-sm/4 gap-1',
leading: 'ps-2',
trailing: 'pe-2',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs',
trailingIcon: 'size-4',
label: 'p-1 text-[10px]/3 gap-1',
item: 'p-1 text-xs gap-1',
itemLeadingIcon: 'size-4',
itemLeadingAvatarSize: '3xs',
itemLeadingChip: 'size-4',
itemLeadingChipSize: 'sm',
itemTrailingIcon: 'size-4',
empty: 'p-2 text-xs'
},
sm: {
base: 'px-2.5 py-1.5 text-sm/4 gap-1.5',
leading: 'ps-2.5',
trailing: 'pe-2.5',
leadingIcon: 'size-4',
leadingAvatarSize: '3xs',
trailingIcon: 'size-4',
label: 'p-1.5 text-[10px]/3 gap-1.5',
item: 'p-1.5 text-xs gap-1.5',
itemLeadingIcon: 'size-4',
itemLeadingAvatarSize: '3xs',
itemLeadingChip: 'size-4',
itemLeadingChipSize: 'sm',
itemTrailingIcon: 'size-4',
empty: 'p-2.5 text-xs'
},
md: {
base: 'px-2.5 py-1.5 text-base/5 gap-1.5',
leading: 'ps-2.5',
trailing: 'pe-2.5',
leadingIcon: 'size-5',
leadingAvatarSize: '2xs',
trailingIcon: 'size-5',
label: 'p-1.5 text-xs gap-1.5',
item: 'p-1.5 text-sm gap-1.5',
itemLeadingIcon: 'size-5',
itemLeadingAvatarSize: '2xs',
itemLeadingChip: 'size-5',
itemLeadingChipSize: 'md',
itemTrailingIcon: 'size-5',
empty: 'p-2.5 text-sm'
},
lg: {
base: 'px-3 py-2 text-base/5 gap-2',
leading: 'ps-3',
trailing: 'pe-3',
leadingIcon: 'size-5',
leadingAvatarSize: '2xs',
trailingIcon: 'size-5',
label: 'p-2 text-xs gap-2',
item: 'p-2 text-sm gap-2',
itemLeadingIcon: 'size-5',
itemLeadingAvatarSize: '2xs',
itemLeadingChip: 'size-5',
itemLeadingChipSize: 'md',
itemTrailingIcon: 'size-5',
empty: 'p-3 text-sm'
},
xl: {
base: 'px-3 py-2 text-base gap-2',
leading: 'ps-3',
trailing: 'pe-3',
leadingIcon: 'size-6',
leadingAvatarSize: 'xs',
trailingIcon: 'size-6',
label: 'p-2 text-sm gap-2',
item: 'p-2 text-base gap-2',
itemLeadingIcon: 'size-6',
itemLeadingAvatarSize: 'xs',
itemLeadingChip: 'size-6',
itemLeadingChipSize: 'lg',
itemTrailingIcon: 'size-6',
empty: 'p-3 text-base'
}
},
variant: {
outline: 'text-highlighted bg-default ring ring-inset ring-accented hover:bg-elevated disabled:bg-default',
soft: 'text-highlighted bg-elevated/50 hover:bg-elevated focus:bg-elevated disabled:bg-elevated/50',
subtle: 'text-highlighted bg-elevated ring ring-inset ring-accented hover:bg-accented/75 disabled:bg-elevated',
ghost: 'text-highlighted bg-transparent hover:bg-elevated focus:bg-elevated disabled:bg-transparent dark:disabled:bg-transparent',
none: 'text-highlighted bg-transparent focus:outline-none'
},
color: {
primary: '',
secondary: '',
success: '',
info: '',
warning: '',
error: '',
neutral: ''
},
leading: {
true: ''
},
trailing: {
true: ''
},
loading: {
true: ''
},
highlight: {
true: ''
},
fixed: {
false: ''
},
type: {
file: 'file:me-1.5 file:font-medium file:text-muted file:outline-none'
},
position: {
popper: {
content: 'data-[state=open]:animate-[scale-in_100ms_var(--ease-out)] data-[state=closed]:animate-[scale-out_100ms_var(--ease-out)]'
},
'item-aligned': {
content: ''
}
},
multiple: {
true: ''
},
virtualize: {
true: {
viewport: 'p-1 isolate'
},
false: {
viewport: 'divide-y divide-default'
}
}
},
compoundVariants: [
{
color: 'primary',
variant: [
'outline',
'subtle'
],
class: 'outline-primary/25 focus-visible:outline-3 focus-visible:ring-primary'
},
{
color: 'secondary',
variant: [
'outline',
'subtle'
],
class: 'outline-secondary/25 focus-visible:outline-3 focus-visible:ring-secondary'
},
{
color: 'success',
variant: [
'outline',
'subtle'
],
class: 'outline-success/25 focus-visible:outline-3 focus-visible:ring-success'
},
{
color: 'info',
variant: [
'outline',
'subtle'
],
class: 'outline-info/25 focus-visible:outline-3 focus-visible:ring-info'
},
{
color: 'warning',
variant: [
'outline',
'subtle'
],
class: 'outline-warning/25 focus-visible:outline-3 focus-visible:ring-warning'
},
{
color: 'error',
variant: [
'outline',
'subtle'
],
class: 'outline-error/25 focus-visible:outline-3 focus-visible:ring-error'
},
{
color: 'primary',
variant: [
'soft',
'ghost'
],
class: 'outline-primary/25 focus-visible:outline-3'
},
{
color: 'secondary',
variant: [
'soft',
'ghost'
],
class: 'outline-secondary/25 focus-visible:outline-3'
},
{
color: 'success',
variant: [
'soft',
'ghost'
],
class: 'outline-success/25 focus-visible:outline-3'
},
{
color: 'info',
variant: [
'soft',
'ghost'
],
class: 'outline-info/25 focus-visible:outline-3'
},
{
color: 'warning',
variant: [
'soft',
'ghost'
],
class: 'outline-warning/25 focus-visible:outline-3'
},
{
color: 'error',
variant: [
'soft',
'ghost'
],
class: 'outline-error/25 focus-visible:outline-3'
},
{
color: 'primary',
highlight: true,
class: 'ring ring-inset ring-primary'
},
{
color: 'secondary',
highlight: true,
class: 'ring ring-inset ring-secondary'
},
{
color: 'success',
highlight: true,
class: 'ring ring-inset ring-success'
},
{
color: 'info',
highlight: true,
class: 'ring ring-inset ring-info'
},
{
color: 'warning',
highlight: true,
class: 'ring ring-inset ring-warning'
},
{
color: 'error',
highlight: true,
class: 'ring ring-inset ring-error'
},
{
color: 'neutral',
variant: [
'outline',
'subtle'
],
class: 'outline-inverted/25 focus-visible:outline-3 focus-visible:ring-inverted'
},
{
color: 'neutral',
variant: [
'soft',
'ghost'
],
class: 'outline-inverted/25 focus-visible:outline-3'
},
{
color: 'neutral',
highlight: true,
class: 'ring ring-inset ring-inverted'
},
{
leading: true,
size: 'xs',
class: 'ps-7'
},
{
leading: true,
size: 'sm',
class: 'ps-8'
},
{
leading: true,
size: 'md',
class: 'ps-9'
},
{
leading: true,
size: 'lg',
class: 'ps-10'
},
{
leading: true,
size: 'xl',
class: 'ps-11'
},
{
trailing: true,
size: 'xs',
class: 'pe-7'
},
{
trailing: true,
size: 'sm',
class: 'pe-8'
},
{
trailing: true,
size: 'md',
class: 'pe-9'
},
{
trailing: true,
size: 'lg',
class: 'pe-10'
},
{
trailing: true,
size: 'xl',
class: 'pe-11'
},
{
loading: true,
leading: true,
class: {
leadingIcon: 'animate-spin'
}
},
{
loading: true,
leading: false,
trailing: true,
class: {
trailingIcon: 'animate-spin'
}
},
{
fixed: false,
size: 'xs',
class: 'md:text-xs'
},
{
fixed: false,
size: 'sm',
class: 'md:text-xs'
},
{
fixed: false,
size: 'md',
class: 'md:text-sm'
},
{
fixed: false,
size: 'lg',
class: 'md:text-sm'
}
],
defaultVariants: {
size: 'md',
color: 'primary',
variant: 'outline',
position: 'popper'
}
}
}
})