리스트박스
리스트박스 (Listbox)
검색, 가상화, 풍부한 항목 렌더링을 지원하는 선택 가능한 항목 목록 컴포넌트예요. v-model로 값을 제어하거나, 상태를 제어하지 않을 때는 default-value prop으로 초기 값을 설정할 수 있어요.
출처: Nuxt UI
본문
사용법 (Usage)
v-model 디렉티브로 Listbox의 값을 제어하거나, 상태를 제어할 필요가 없을 때 default-value prop으로 초기 값을 설정할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
icon: "i-lucide-map-pin",
value: "ES"
},
{
label: "Netherlands",
icon: "i-lucide-map-pin",
value: "NL"
},
{
label: "Poland",
icon: "i-lucide-map-pin",
value: "PL"
},
{
label: "Belgium",
icon: "i-lucide-map-pin",
value: "BE"
},
{
label: "Portugal",
icon: "i-lucide-map-pin",
value: "PT"
},
{
label: "Austria",
icon: "i-lucide-map-pin",
value: "AT"
},
{
label: "Sweden",
icon: "i-lucide-map-pin",
value: "SE"
}
])
const value = ref({
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
})
</script>
<template>
<UListbox v-model="value" :items="items" />
</template>
항목 (Items)
items prop을 다음 속성을 가진 객체 배열로 전달해요.
label?: stringdescription?: stringtype?: "label" | "separator" | "item"icon?: stringavatar?: AvatarPropschip?: ChipPropsdisabled?: booleanonSelect?: (e: Event) => voidclass?: anyui?: { label?: ClassNameValue, separator?: ClassNameValue, item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, ... }
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
description: "The Hexagon",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
description: "The Federal Republic",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
description: "The Boot",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
description: "The Bull Skin",
icon: "i-lucide-map-pin",
value: "ES"
}
])
</script>
<template>
<UListbox :items="items" />
</template>
items prop에 배열의 배열을 전달해 항목 그룹을 분리해 표시할 수도 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[][]>([
[
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
}
],
[
{
label: "Brazil",
icon: "i-lucide-map-pin",
value: "BR"
},
{
label: "Argentina",
icon: "i-lucide-map-pin",
value: "AR"
}
]
])
</script>
<template>
<UListbox :items="items" />
</template>
다중 선택 (Multiple)
multiple prop을 사용해 여러 항목을 선택할 수 있어요. 이 경우 v-model은 배열이 돼요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
icon: "i-lucide-map-pin",
value: "ES"
}
])
</script>
<template>
<UListbox multiple :items="items" />
</template>
값 키 (Value Key)
value-key prop을 사용해 전체 객체 대신 객체의 특정 속성 하나를 바인딩할 수 있어요. 기본값은 undefined예요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
icon: "i-lucide-map-pin",
value: "ES"
}
])
const value = ref("FR")
</script>
<template>
<UListbox v-model="value" value-key="value" :items="items" class="w-full" />
</template>
필터 (Filter)
filter prop을 사용해 필터 입력을 표시하거나, 객체를 전달해 Input 컴포넌트를 커스텀할 수 있어요. 기본값은 false예요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
icon: "i-lucide-map-pin",
value: "ES"
},
{
label: "Netherlands",
icon: "i-lucide-map-pin",
value: "NL"
},
{
label: "Poland",
icon: "i-lucide-map-pin",
value: "PL"
}
])
</script>
<template>
<UListbox :filter="{
placeholder: 'Filter...',
icon: 'i-lucide-search'
}" :items="items" />
</template>
선택 아이콘 (Selected Icon)
selected-icon prop을 사용해 항목이 선택되었을 때 표시될 아이콘을 커스텀해요. 기본값은 i-lucide-check예요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
icon: "i-lucide-map-pin",
value: "ES"
}
])
const value = ref("FR")
</script>
<template>
<UListbox v-model="value" selected-icon="i-lucide-flame" value-key="value" :items="items" class="w-full" />
</template>
크기 (Size)
size prop을 사용해 Listbox의 크기를 변경해요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
icon: "i-lucide-map-pin",
value: "ES"
}
])
</script>
<template>
<UListbox size="xl" :items="items" />
</template>
로딩 (Loading)
loading prop을 사용해 로딩 표시기를 보여줘요. loading-icon prop으로 아이콘을 커스텀할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
}
])
</script>
<template>
<UListbox loading :items="items" />
</template>
비활성화 (Disabled)
disabled prop을 사용해 Listbox와의 모든 사용자 상호작용을 막아요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
icon: "i-lucide-map-pin",
value: "ES"
}
])
</script>
<template>
<UListbox disabled :items="items" />
</template>
예시 (Examples)
항목 타입 사용하기 (With items type)
type 속성을 separator로 사용하면 항목 사이에 구분선을, label로 사용하면 라벨을 표시할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[][]>([
[
{
type: "label",
label: "Fruits"
},
{
label: "Apple"
},
{
label: "Banana"
},
{
label: "Blueberry"
},
{
label: "Grapes"
},
{
label: "Pineapple"
}
],
[
{
type: "label",
label: "Vegetables"
},
{
label: "Aubergine"
},
{
label: "Broccoli"
},
{
label: "Carrot"
},
{
label: "Courgette"
},
{
label: "Leek"
}
]
])
</script>
<template>
<UListbox :items="items" />
</template>
[!NOTE]
label항목을 그룹 헤딩으로 사용할 때는 배열의 배열을 전달해야 검색 시 라벨이 그 그룹과 함께 걸러져요.
항목에 아이콘 넣기 (With icon in items)
icon 속성을 사용해 항목 안에 Icon을 표시할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "Backlog",
icon: "i-lucide-circle-help",
value: "backlog"
},
{
label: "Todo",
icon: "i-lucide-circle-plus",
value: "todo"
},
{
label: "In Progress",
icon: "i-lucide-circle-arrow-up",
value: "in_progress"
},
{
label: "Done",
icon: "i-lucide-circle-check",
value: "done"
}
])
</script>
<template>
<UListbox :items="items" />
</template>
항목에 아바타 넣기 (With avatar in items)
avatar 속성을 사용해 항목 안에 Avatar를 표시할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "benjamincanac",
avatar: {
src: "https://github.com/benjamincanac.png"
}
},
{
label: "HugoRCD",
avatar: {
src: "https://github.com/HugoRCD.png"
}
},
{
label: "atinux",
avatar: {
src: "https://github.com/atinux.png"
}
},
{
label: "romhml",
avatar: {
src: "https://github.com/romhml.png"
}
}
])
</script>
<template>
<UListbox :items="items" />
</template>
항목에 칩 넣기 (With chip in items)
chip 속성을 사용해 항목 안에 Chip을 표시할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "bug",
chip: {
color: "error"
}
},
{
label: "feature",
chip: {
color: "success"
}
},
{
label: "enhancement",
chip: {
color: "info"
}
}
])
</script>
<template>
<UListbox :items="items" />
</template>
항목에 설명 넣기 (With description in items)
description 속성을 사용해 라벨 아래에 추가 텍스트를 표시할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items = ref<ListboxItem[]>([
{
label: "France",
description: "The Hexagon",
icon: "i-lucide-map-pin",
value: "FR"
},
{
label: "Germany",
description: "The Federal Republic",
icon: "i-lucide-map-pin",
value: "DE"
},
{
label: "Italy",
description: "The Boot",
icon: "i-lucide-map-pin",
value: "IT"
},
{
label: "Spain",
description: "The Bull Skin",
icon: "i-lucide-map-pin",
value: "ES"
}
])
</script>
<template>
<UListbox :items="items" />
</template>
선택 항목 제어하기 (Control selected item(s))
default-value prop 또는 v-model 디렉티브를 사용해 선택된 항목을 제어할 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items: ListboxItem[] = [
{ label: 'France', icon: 'i-lucide-map-pin', value: 'FR' },
{ label: 'Germany', icon: 'i-lucide-map-pin', value: 'DE' },
{ label: 'Italy', icon: 'i-lucide-map-pin', value: 'IT' },
{ label: 'Spain', icon: 'i-lucide-map-pin', value: 'ES' },
{ label: 'Netherlands', icon: 'i-lucide-map-pin', value: 'NL' },
{ label: 'Poland', icon: 'i-lucide-map-pin', value: 'PL' }
]
const value = ref<ListboxItem>(items[2]!)
</script>
<template>
<UListbox
v-model="value"
:items="items"
class="w-full"
/>
</template>
검색어 제어하기 (Control search term)
v-model:search-term 디렉티브를 사용해 검색어를 제어할 수 있어요.
<script setup lang="ts">
const searchTerm = ref('F')
const items = ref([
{ label: 'France', icon: 'i-lucide-map-pin', value: 'FR' },
{ label: 'Germany', icon: 'i-lucide-map-pin', value: 'DE' },
{ label: 'Italy', icon: 'i-lucide-map-pin', value: 'IT' },
{ label: 'Spain', icon: 'i-lucide-map-pin', value: 'ES' },
{ label: 'Netherlands', icon: 'i-lucide-map-pin', value: 'NL' },
{ label: 'Poland', icon: 'i-lucide-map-pin', value: 'PL' }
])
const value = ref()
</script>
<template>
<UListbox v-model="value" v-model:search-term="searchTerm" filter :items="items" class="w-full" />
</template>
필터 무시하기 (With ignore filter)
ignore-filter prop을 true로 설정하면 내부 검색을 비활성화하고 자신만의 검색 로직을 사용할 수 있어요.
<script setup lang="ts">
import { refDebounced } from '@vueuse/core'
const searchTerm = ref('')
const searchTermDebounced = refDebounced(searchTerm, 200)
const { data: users, status, execute } = await useLazyFetch('https://jsonplaceholder.typicode.com/users', {
key: 'listbox-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
})
onMounted(() => {
execute()
})
</script>
<template>
<UListbox
v-model:search-term="searchTerm"
:items="users || []"
:filter="{
icon: 'i-lucide-search',
loading: status === 'pending'
}"
ignore-filter
class="w-full"
/>
</template>
[!NOTE]
이 예시는 API 호출을 디바운스하기 위해
refDebounced를 사용해요.
필터 필드 사용하기 (With filter fields)
filter-fields prop에 필드 배열을 전달해 그 필드 기준으로 필터링할 수 있어요. 기본값은 [labelKey]예요.
<script setup lang="ts">
const { data: users, status, execute } = await useLazyFetch('https://jsonplaceholder.typicode.com/users', {
key: 'typicode-users-email',
transform: (data: { id: number, name: string, email: string }[]) => {
return data?.map(user => ({
label: user.name,
email: user.email,
value: String(user.id),
avatar: { src: `https://i.pravatar.cc/120?img=${user.id}`, loading: 'lazy' as const }
}))
},
immediate: false
})
onMounted(() => {
execute()
})
</script>
<template>
<UListbox
:items="users || []"
:loading="status === 'pending'"
:filter-fields="['label', 'email']"
filter
class="w-full"
>
<template #item-label="{ item }">
{{ item.label }}
<span class="text-muted">
{{ item.email }}
</span>
</template>
</UListbox>
</template>
가상화 사용하기 (With virtualization)
virtualize prop을 사용해 큰 목록에 대한 가상화를 활성화할 수 있어요. 불리언 또는 { estimateSize: 32, overscan: 12 } 같은 옵션 객체로 전달하면 돼요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items: ListboxItem[] = Array.from({ length: 1000 }, (_, i) => ({
label: `Item ${i + 1}`,
icon: 'i-lucide-file',
value: i + 1
}))
const value = ref<ListboxItem[]>([])
</script>
<template>
<UListbox
v-model="value"
:items="items"
multiple
virtualize
class="w-full"
/>
</template>
전송 목록으로 사용하기 (As a transfer list)
두 개의 Listbox 컴포넌트를 Button 컨트롤과 조합해 전송 목록(transfer list) 패턴을 만들 수 있어요.
<script setup lang="ts">
import type { ListboxItem } from '@nuxt/ui'
const items: ListboxItem[] = [
{ label: 'France', icon: 'i-lucide-map-pin', value: 'FR' },
{ label: 'Germany', icon: 'i-lucide-map-pin', value: 'DE' },
{ label: 'Italy', icon: 'i-lucide-map-pin', value: 'IT' },
{ label: 'Spain', icon: 'i-lucide-map-pin', value: 'ES' },
{ label: 'Netherlands', icon: 'i-lucide-map-pin', value: 'NL' },
{ label: 'Poland', icon: 'i-lucide-map-pin', value: 'PL' },
{ label: 'Belgium', icon: 'i-lucide-map-pin', value: 'BE' },
{ label: 'Portugal', icon: 'i-lucide-map-pin', value: 'PT' }
]
const targetItems = ref<ListboxItem[]>([])
const sourceSelection = ref<ListboxItem[]>([])
const targetSelection = ref<ListboxItem[]>([])
const sourceItems = computed(() => items.filter(item => !targetItems.value.some(t => t.value === item.value)))
function transferSelected() {
targetItems.value = [...targetItems.value, ...sourceSelection.value]
sourceSelection.value = []
}
function removeSelected() {
targetItems.value = targetItems.value.filter(item => !targetSelection.value.some(t => t.value === item.value))
targetSelection.value = []
}
</script>
<template>
<div class="flex items-stretch gap-4 w-full">
<div class="flex flex-col flex-1 gap-1">
<span class="text-sm font-medium text-highlighted">Available</span>
<UListbox
v-model="sourceSelection"
:items="sourceItems"
multiple
filter
class="size-full"
/>
</div>
<div class="flex flex-col items-center justify-center gap-1">
<UButton
icon="i-lucide-chevron-right"
color="neutral"
variant="outline"
:disabled="!sourceSelection.length"
@click="transferSelected"
/>
<UButton
icon="i-lucide-chevron-left"
color="neutral"
variant="outline"
:disabled="!targetSelection.length"
@click="removeSelected"
/>
</div>
<div class="flex flex-col flex-1 gap-1">
<span class="text-sm font-medium text-highlighted">Selected</span>
<UListbox
v-model="targetSelection"
:items="targetItems"
multiple
filter
class="size-full"
/>
</div>
</div>
</template>
API
Props
/**
* Props for the Listbox component
*/
interface ListboxProps {
id?: string | undefined;
/**
* The element or component this component should render as.
* @default 'div'
*/
as?: any;
/**
* @default 'primary'
*/
color?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
/**
* @default 'md'
*/
size?: "sm" | "md" | "xs" | "lg" | "xl" | undefined;
/**
* The items to display in the list.
*/
items?: T | undefined;
/**
* The controlled value of the Listbox. Can be bound with `v-model`.
*/
modelValue?: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, undefined>, Mod>, Mod>, Mod> | undefined;
modelModifiers?: Mod | undefined;
/**
* The default value when not controlled.
*/
defaultValue?: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, undefined>, Mod>, Mod>, Mod> | undefined;
/**
* Whether multiple items can be selected.
* @default false
*/
multiple?: M | undefined;
/**
* When `items` is an array of objects, select the field to use as the value instead of the object itself.
* @default undefined
*/
valueKey?: VK | undefined;
/**
* The key used to get the label from the item.
* @default 'label'
*/
labelKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
/**
* The key used to get the description from the item.
* @default 'description'
*/
descriptionKey?: keyof Extract<NestedItem<T>, object> & string | DotPathKeys<Extract<NestedItem<T>, object>> | undefined;
/**
* Whether the list is in a loading state.
*/
loading?: boolean | undefined;
/**
* The icon displayed when loading.
* @default appConfig.ui.icons.loading
*/
loadingIcon?: any;
/**
* Whether to display a filter input or not.
* Can be an object to pass additional props to the input.
* `{ placeholder: 'Search...', variant: 'none' }`{lang="ts-type"}
* @default false
*/
filter?: boolean | Omit<InputProps<AcceptableValue, ModelModifiers>, "modelValue" | "defaultValue"> | undefined;
/**
* The fields to filter by.
* @default [labelKey]
*/
filterFields?: string[] | undefined;
/**
* When `true`, disable the default filters, useful for custom filtering (useAsyncData, useFetch, etc.).
* @default false
*/
ignoreFilter?: boolean | undefined;
/**
* The icon displayed when an item is selected.
* @default appConfig.ui.icons.check
*/
selectedIcon?: any;
/**
* Enable virtualization for large lists.
* @default false
*/
virtualize?: boolean | { overscan?: number | undefined; estimateSize?: number | ((index: number) => number) | undefined; } | undefined;
/**
* Highlight the ring color like a focus state.
*/
highlight?: boolean | undefined;
autofocus?: boolean | undefined;
/**
* @default 0
*/
autofocusDelay?: number | undefined;
ui?: { root?: SlotClass; input?: SlotClass; content?: SlotClass; group?: SlotClass; label?: SlotClass; separator?: SlotClass; empty?: SlotClass; loading?: SlotClass; loadingIcon?: SlotClass; item?: SlotClass; itemLeadingIcon?: SlotClass; itemLeadingAvatar?: SlotClass; itemLeadingAvatarSize?: SlotClass; itemLeadingChip?: SlotClass; itemLeadingChipSize?: SlotClass; itemWrapper?: SlotClass; itemLabel?: SlotClass; itemDescription?: SlotClass; itemTrailing?: SlotClass; itemTrailingIcon?: SlotClass; } | undefined;
/**
* Use this to compare objects by a particular field, or pass your own comparison function for complete control over how objects are compared.
*/
by?: string | (a: AcceptableValue, b: AcceptableValue): boolean | undefined;
/**
* When `true`, prevents the user from interacting with listbox
*/
disabled?: boolean | undefined;
/**
* When `true`, hover over item will trigger highlight
* @default true
*/
highlightOnHover?: boolean | undefined;
/**
* The name of the field. Submitted with its owning form as part of a name/value pair.
*/
name?: string | undefined;
/**
* The orientation of the listbox. <br>Mainly so arrow navigation is done accordingly (left & right vs. up & down)
*/
orientation?: "vertical" | "horizontal" | undefined;
/**
* When `true`, indicates that the user must set the value before the owning form can be submitted.
*/
required?: boolean | undefined;
/**
* How multiple selection should behave in the collection.
* @default 'toggle'
*/
selectionBehavior?: "replace" | "toggle" | undefined;
/**
* @default ''
*/
searchTerm?: string | undefined;
}
Slots
/**
* Slots for the Listbox component
*/
interface ListboxSlots {
loading(): any;
empty(): any;
item(): any;
item-leading(): any;
item-label(): any;
item-description(): any;
item-trailing(): any;
}
Emits
/**
* Emitted events for the Listbox component
*/
interface ListboxEmits {
entryFocus: (payload: [event: CustomEvent<any>]) => void;
highlight: (payload: [payload: { ref: HTMLElement; value: AcceptableValue; } | undefined]) => void;
leave: (payload: [event: Event]) => void;
change: (payload: [event: Event]) => void;
update:modelValue: (payload: [value: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, undefined>, Mod>, Mod>, Mod>]) => void;
update:searchTerm: (payload: [value: string]) => void;
}
테마 (Theme)
export default defineAppConfig({
ui: {
listbox: {
slots: {
root: 'flex flex-col min-h-0 min-w-0 ring ring-inset ring-default rounded-lg overflow-hidden',
input: 'border-b border-default',
content: 'relative overflow-y-auto flex-1 max-h-60 scroll-py-1 focus:outline-none',
group: 'p-1 isolate',
label: 'font-semibold text-highlighted',
separator: '-mx-1 my-1 h-px bg-border',
empty: 'text-center text-muted',
loading: 'flex items-center justify-center text-muted',
loadingIcon: 'animate-spin shrink-0',
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: '',
itemWrapper: 'flex-1 flex flex-col min-w-0',
itemLabel: 'truncate',
itemDescription: 'truncate text-muted',
itemTrailing: 'ms-auto inline-flex gap-1.5 items-center',
itemTrailingIcon: 'shrink-0'
},
variants: {
size: {
xs: {
label: 'p-1 text-[10px]/3 gap-1',
empty: 'py-3 text-xs',
loading: 'py-3',
loadingIcon: 'size-4',
item: 'p-1 text-xs gap-1',
itemLeadingIcon: 'size-4',
itemLeadingAvatarSize: '3xs',
itemLeadingChip: 'size-4',
itemLeadingChipSize: 'sm',
itemTrailingIcon: 'size-4'
},
sm: {
label: 'p-1.5 text-[10px]/3 gap-1.5',
empty: 'py-4 text-xs',
loading: 'py-4',
loadingIcon: 'size-4',
item: 'p-1.5 text-xs gap-1.5',
itemLeadingIcon: 'size-4',
itemLeadingAvatarSize: '3xs',
itemLeadingChip: 'size-4',
itemLeadingChipSize: 'sm',
itemTrailingIcon: 'size-4'
},
md: {
label: 'p-1.5 text-xs gap-1.5',
empty: 'py-6 text-sm',
loading: 'py-6',
loadingIcon: 'size-5',
item: 'p-1.5 text-sm gap-1.5',
itemLeadingIcon: 'size-5',
itemLeadingAvatarSize: '2xs',
itemLeadingChip: 'size-5',
itemLeadingChipSize: 'md',
itemTrailingIcon: 'size-5'
},
lg: {
label: 'p-2 text-xs gap-2',
empty: 'py-7 text-sm',
loading: 'py-7',
loadingIcon: 'size-5',
item: 'p-2 text-sm gap-2',
itemLeadingIcon: 'size-5',
itemLeadingAvatarSize: '2xs',
itemLeadingChip: 'size-5',
itemLeadingChipSize: 'md',
itemTrailingIcon: 'size-5'
},
xl: {
label: 'p-2 text-sm gap-2',
empty: 'py-8 text-base',
loading: 'py-8',
loadingIcon: 'size-6',
item: 'p-2 text-base gap-2',
itemLeadingIcon: 'size-6',
itemLeadingAvatarSize: 'xs',
itemLeadingChip: 'size-6',
itemLeadingChipSize: 'lg',
itemTrailingIcon: 'size-6',
itemDescription: 'text-sm'
}
},
color: {
primary: {
root: 'outline-primary/25 has-focus-visible:outline-3 has-focus-visible:ring-primary'
},
secondary: {
root: 'outline-secondary/25 has-focus-visible:outline-3 has-focus-visible:ring-secondary'
},
success: {
root: 'outline-success/25 has-focus-visible:outline-3 has-focus-visible:ring-success'
},
info: {
root: 'outline-info/25 has-focus-visible:outline-3 has-focus-visible:ring-info'
},
warning: {
root: 'outline-warning/25 has-focus-visible:outline-3 has-focus-visible:ring-warning'
},
error: {
root: 'outline-error/25 has-focus-visible:outline-3 has-focus-visible:ring-error'
},
neutral: {
root: 'outline-inverted/25 has-focus-visible:outline-3 has-focus-visible:ring-inverted'
}
},
virtualize: {
true: {
content: 'p-1 isolate'
},
false: {
content: 'divide-y divide-default'
}
},
disabled: {
true: {
root: 'opacity-75 cursor-not-allowed'
}
},
highlight: {
true: ''
}
},
compoundVariants: [
{
color: 'primary',
highlight: true,
class: {
root: 'ring ring-inset ring-primary'
}
},
{
color: 'secondary',
highlight: true,
class: {
root: 'ring ring-inset ring-secondary'
}
},
{
color: 'success',
highlight: true,
class: {
root: 'ring ring-inset ring-success'
}
},
{
color: 'info',
highlight: true,
class: {
root: 'ring ring-inset ring-info'
}
},
{
color: 'warning',
highlight: true,
class: {
root: 'ring ring-inset ring-warning'
}
},
{
color: 'error',
highlight: true,
class: {
root: 'ring ring-inset ring-error'
}
},
{
color: 'neutral',
highlight: true,
class: {
root: 'ring ring-inset ring-inverted'
}
}
],
defaultVariants: {
color: 'primary',
size: 'md'
}
}
}
})
변경 내역 (Changelog)
사이트맵 (Sitemap)
전체 사이트맵에서 모든 페이지를 확인할 수 있어요.