InputMenu
입력할 때 실시간으로 추천 항목을 보여 주는 자동완성 입력 컴포넌트예요.
출처: Nuxt UI
본문
사용법
v-model 디렉티브로 InputMenu의 값을 제어하거나, 상태를 제어할 필요가 없을 때는 default-value prop으로 초기 값을 설정할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" :items="items" />
</template>
[!TIP]
자동완성 기능을 제공하는 Reka UI의
Combobox컴포넌트를 활용하려면Input대신 이 컴포넌트를 사용해 주세요.
[!NOTE]
이 컴포넌트는
SelectMenu와 비슷하지만 Select 대신 Input을 사용해요.
Items
items prop에 문자열, 숫자, 불리언 배열을 전달할 수 있어요:
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" :items="items" />
</template>
다음 속성을 가진 객체 배열도 전달할 수 있어요:
label?: stringtype?: "label" | "separator" | "item"icon?: stringavatar?: AvatarPropschip?: ChipPropsdisabled?: booleanonSelect?: (e: Event) => voidclass?: anyui?: { tagsItem?: ClassNameValue, tagsItemText?: ClassNameValue, tagsItemDelete?: ClassNameValue, tagsItemDeleteIcon?: ClassNameValue, label?: ClassNameValue, separator?: ClassNameValue, item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingAvatarSize?: ClassNameValue, itemLeadingAvatar?: ClassNameValue, itemLeadingChip?: ClassNameValue, itemLeadingChipSize?: ClassNameValue, itemLabel?: ClassNameValue, itemTrailing?: ClassNameValue, itemTrailingIcon?: ClassNameValue }
<script setup lang="ts">
import type { InputMenuItem } from '@nuxt/ui'
const items = ref<InputMenuItem[]>([
{
label: "Backlog"
},
{
label: "Todo"
},
{
label: "In Progress"
},
{
label: "Done"
}
])
const value = ref({
label: "Todo"
})
</script>
<template>
<UInputMenu v-model="value" :items="items" />
</template>
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>
<UInputMenu v-model="value" :items="items" />
</template>
Value Key
value-key prop을 사용하면 객체 전체가 아니라 객체의 단일 속성만 바인딩할 수 있어요. 기본값은 undefined예요.
<script setup lang="ts">
import type { InputMenuItem } from '@nuxt/ui'
const items = ref<InputMenuItem[]>([
{
label: "Backlog",
id: "backlog"
},
{
label: "Todo",
id: "todo"
},
{
label: "In Progress",
id: "in_progress"
},
{
label: "Done",
id: "done"
}
])
const value = ref("todo")
</script>
<template>
<UInputMenu v-model="value" value-key="id" :items="items" />
</template>
[!TIP]
model-value가 객체일 때byprop을 사용하면 참조(reference) 대신 특정 필드로 객체를 비교할 수 있어요.
Multiple
multiple prop을 사용하면 여러 항목을 선택할 수 있고, 선택한 항목은 태그로 표시돼요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref([
"Backlog",
"Todo"
])
</script>
<template>
<UInputMenu v-model="value" multiple :items="items" />
</template>
[!CAUTION]
default-valueprop이나v-model디렉티브에 배열을 전달해 주세요.
Delete Icon
multiple일 때 delete-icon prop으로 태그의 삭제 Icon을 커스터마이즈할 수 있어요. 기본값은 i-lucide-x예요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref([
"Backlog",
"Todo"
])
</script>
<template>
<UInputMenu v-model="value" multiple delete-icon="i-lucide-trash" :items="items" />
</template>
Nuxt:
[!TIP] 참고: /docs/getting-started/integrations/icons/nuxt#theme
You can customize this icon globally in your
app.config.tsunderui.icons.closekey.
Vue:
[!TIP] 참고: /docs/getting-started/integrations/icons/vue#theme
You can customize this icon globally in your
vite.config.tsunderui.icons.closekey.
Placeholder
placeholder prop으로 플레이스홀더 텍스트를 설정할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
</script>
<template>
<UInputMenu placeholder="Select status" :items="items" />
</template>
Mode 4.8+
mode prop을 autocomplete로 설정하면 InputMenu를 추천이 있는 자유 형식 텍스트 입력으로 바꿀 수 있어요. modelValue는 선택된 항목 대신 입력 텍스트(string)가 돼요.
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('')
</script>
<template>
<UInputMenu
v-model="value"
mode="autocomplete"
:items="items"
:trailing-icon="false"
:content="{ hideWhenEmpty: true }"
placeholder="Type a status..."
/>
</template>
[!CAUTION]
mode가autocomplete일 때multiple,by,resetSearchTermOnSelect,resetModelValueOnClear는 적용되지 않아요.
[!TIP]
일치하는 추천이 없을 때 메뉴를 숨기려면
content.hideWhenEmptyprop을 사용해 주세요.
Content
content prop으로 InputMenu 콘텐츠가 렌더링되는 방식을 제어할 수 있어요. 예를 들어 align이나 side 같은 옵션을 설정할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" :content="{
align: 'center',
side: 'bottom',
sideOffset: 8
}" :items="items" />
</template>
Arrow
arrow prop으로 InputMenu에 화살표를 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" arrow :items="items" />
</template>
Color
color prop으로 InputMenu가 포커스될 때의 링(ring) 색상을 바꿀 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" color="neutral" highlight :items="items" />
</template>
[!NOTE]
여기서
highlightprop은 포커스 상태를 보여 주기 위해 사용돼요. 검증 에러가 발생할 때 내부적으로 사용돼요.
Variant
variant prop으로 InputMenu의 변형을 바꿀 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" color="neutral" variant="subtle" :highlight="false" :items="items" />
</template>
Size
size prop으로 InputMenu의 크기를 바꿀 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" size="xl" :items="items" />
</template>
Icon
icon prop으로 InputMenu 안에 Icon을 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" icon="i-lucide-search" size="md" :items="items" />
</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>
<UInputMenu v-model="value" trailing-icon="i-lucide-arrow-down" size="md" :items="items" />
</template>
Nuxt:
[!TIP] 참고: /docs/getting-started/integrations/icons/nuxt#theme
app.config.ts의ui.icons.chevronDown키에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] 참고: /docs/getting-started/integrations/icons/vue#theme
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>
<UInputMenu v-model="value" selected-icon="i-lucide-flame" size="md" :items="items" />
</template>
Nuxt:
[!TIP] 참고: /docs/getting-started/integrations/icons/nuxt#theme
app.config.ts의ui.icons.check키에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] 참고: /docs/getting-started/integrations/icons/vue#theme
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>
<UInputMenu v-model="value" clear :items="items" />
</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>
<UInputMenu v-model="value" clear clear-icon="i-lucide-trash" :items="items" />
</template>
Nuxt:
[!TIP] 참고: /docs/getting-started/integrations/icons/nuxt#theme
You can customize this icon globally in your
app.config.tsunderui.icons.closekey.
Vue:
[!TIP] 참고: /docs/getting-started/integrations/icons/vue#theme
You can customize this icon globally in your
vite.config.tsunderui.icons.closekey.
Avatar
avatar prop으로 InputMenu 안에 Avatar를 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Nuxt",
"NuxtHub",
"NuxtLabs",
"Nuxt Modules",
"Nuxt Community"
])
const value = ref("Nuxt")
</script>
<template>
<UInputMenu v-model="value" :avatar="{
src: 'https://github.com/nuxt.png',
loading: 'lazy'
}" :items="items" />
</template>
Loading
loading prop으로 InputMenu에 로딩 아이콘을 표시할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
const value = ref("Backlog")
</script>
<template>
<UInputMenu v-model="value" loading :trailing="false" :items="items" />
</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>
<UInputMenu v-model="value" loading loading-icon="i-lucide-loader" :items="items" />
</template>
Nuxt:
[!TIP] 참고: /docs/getting-started/integrations/icons/nuxt#theme
app.config.ts의ui.icons.loading키에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.
Vue:
[!TIP] 참고: /docs/getting-started/integrations/icons/vue#theme
vite.config.ts의ui.icons.loading키에서 이 아이콘을 전역으로 커스터마이즈할 수 있어요.
Disabled
disabled prop으로 InputMenu를 비활성화할 수 있어요.
<script setup lang="ts">
const items = ref([
"Backlog",
"Todo",
"In Progress",
"Done"
])
</script>
<template>
<UInputMenu disabled placeholder="Select status" :items="items" />
</template>
예시
items type 사용하기
type 속성을 separator로 설정하면 항목 사이에 구분선을, label로 설정하면 라벨을 표시할 수 있어요.
<script setup lang="ts">
import type { InputMenuItem } from '@nuxt/ui'
const items = ref<InputMenuItem[]>([
[
{
type: "label",
label: "Fruits"
},
"Apple",
"Banana",
"Blueberry",
"Grapes",
"Pineapple"
],
[
{
type: "label",
label: "Vegetables"
},
"Aubergine",
"Broccoli",
"Carrot",
"Courgette",
"Leek"
]
])
const value = ref("Apple")
</script>
<template>
<UInputMenu v-model="value" :items="items" />
</template>
[!NOTE]
label항목을 그룹 제목으로 사용할 때는 배열의 배열을 전달해 주세요. 그러면 검색할 때 라벨이 그룹과 함께 필터링돼요.
항목에 아이콘 사용하기
icon 속성을 사용하면 항목 안에 Icon을 표시할 수 있어요.
<script setup lang="ts">
import type { InputMenuItem } 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 InputMenuItem[])
const value = ref(items.value[0])
</script>
<template>
<UInputMenu v-model="value" :icon="value?.icon" :items="items" />
</template>
[!TIP]
#leading슬롯을 사용해 선택된 아이콘을 표시할 수도 있어요.
항목에 아바타 사용하기
avatar 속성을 사용하면 항목 안에 Avatar를 표시할 수 있어요.
<script setup lang="ts">
import type { InputMenuItem } 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 InputMenuItem[])
const value = ref(items.value[0])
</script>
<template>
<UInputMenu v-model="value" :avatar="value?.avatar" :items="items" />
</template>
[!TIP]
#leading슬롯을 사용해 선택된 아바타를 표시할 수도 있어요.
항목에 칩 사용하기
chip 속성을 사용하면 항목 안에 Chip을 표시할 수 있어요.
<script setup lang="ts">
import type { InputMenuItem, 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 InputMenuItem[])
const value = ref(items.value[0])
</script>
<template>
<UInputMenu v-model="value" :items="items">
<template #leading="{ modelValue, ui }">
<UChip
v-if="modelValue"
v-bind="modelValue.chip"
inset
standalone
:size="(ui.itemLeadingChipSize() as ChipProps['size'])"
:class="ui.itemLeadingChip()"
/>
</template>
</UInputMenu>
</template>
[!NOTE]
이 예시에서는
#leading슬롯을 사용해 선택된 칩을 표시해요.
열림 상태 제어하기
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>
<UInputMenu v-model="value" v-model:open="open" :items="items" />
</template>
[!NOTE]
이 예시에서는
defineShortcuts를 활용해O키를 눌러 InputMenu를 열고 닫을 수 있어요.
포커스 시 열림 상태 제어하기
open-on-focus나 open-on-click prop을 사용하면 입력이 포커스되거나 클릭됐을 때 메뉴를 열 수 있어요.
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const selected = ref('Backlog')
</script>
<template>
<UInputMenu
v-model="selected"
:items="items"
open-on-focus
/>
</template>
검색어 제어하기
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>
<UInputMenu v-model="value" v-model:search-term="searchTerm" :items="items" />
</template>
회전하는 아이콘 사용하기
InputMenu의 열림 상태를 나타내는 회전 아이콘 예시예요.
<script setup lang="ts">
const items = ref(['Backlog', 'Todo', 'In Progress', 'Done'])
const value = ref('Backlog')
</script>
<template>
<UInputMenu
v-model="value"
:items="items"
:ui="{
trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200'
}"
/>
</template>
항목 만들기 사용하기
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>
<UInputMenu
v-model="value"
create-item
:items="items"
class="w-48"
@create="onCreate"
/>
</template>
[!NOTE]
기본적으로 일치하는 항목이 없을 때 만들기 옵션이 표시돼요. 비슷한 값이 있어도 항상 표시하려면
always로 설정해 주세요.
[!TIP] 참고: #emits
항목 생성은
@create이벤트로 처리해 주세요. 이벤트와 항목을 인자로 받아요.
가져온 항목 사용하기
API에서 항목을 가져와 InputMenu에서 사용할 수 있어요.
<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>
<UInputMenu
:items="users"
:loading="status === 'pending'"
icon="i-lucide-user"
placeholder="Select user"
@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>
</UInputMenu>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해 메뉴가 열릴 때만 데이터를 가져와 페이지 로드 시 불필요한 API 호출을 피해요.
필터 무시하기
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: 'input-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>
<UInputMenu
v-model:search-term="searchTerm"
:items="users"
:loading="status === 'pending'"
ignore-filter
icon="i-lucide-user"
placeholder="Select user"
@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>
</UInputMenu>
</template>
[!NOTE]
이 예시는
refDebounced를 사용해 API 호출을 디바운스해요.immediate: false로 fetch를 지연하므로 메뉴가 열릴 때까지 요청하지 않아요.
필터 필드 사용하기
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>
<UInputMenu
: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>
</UInputMenu>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해 메뉴가 열릴 때만 데이터를 가져와 페이지 로드 시 불필요한 API 호출을 피해요.
가상화 사용하기 4.1+
virtualize prop을 불리언으로 설정하거나 { estimateSize: 32, overscan: 12 } 같은 옵션을 가진 객체로 설정해 대규모 목록의 가상화를 활성화할 수 있어요.
[!WARNING] 참고: https://github.com/unovue/reka-ui/issues/1885
활성화하면 Reka UI의 제한 때문에 모든 그룹이 하나의 목록으로 평평해져요.
<script setup lang="ts">
import type { InputMenuItem } from '@nuxt/ui'
const items: InputMenuItem[] = Array(1000).fill(0).map((_, i) => ({
label: `item-${i}`,
value: i
}))
</script>
<template>
<UInputMenu virtualize :items="items" class="w-48" />
</template>
무한 스크롤 사용하기 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: 'input-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 inputMenu = useTemplateRef('inputMenu')
onMounted(() => {
useInfiniteScroll(() => inputMenu.value?.viewportRef, () => {
skip.value += 10
}, {
canLoadMore: () => {
return status.value !== 'pending'
}
})
})
</script>
<template>
<UInputMenu
ref="inputMenu"
placeholder="Select user"
:items="users"
@update:open="onOpen"
/>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해 사용자가 스크롤할 때만 데이터를 불러와요.
콘텐츠를 전체 폭으로 사용하기
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>
<UInputMenu
:items="users"
icon="i-lucide-user"
placeholder="Select user"
:ui="{ content: 'min-w-fit' }"
@update:open="onOpen"
>
<template #item-label="{ item }">
{{ item.label }}
<span class="text-muted">
{{ item.email }}
</span>
</template>
</UInputMenu>
</template>
[!TIP]
app.config.ts에서 콘텐츠 폭을 전역으로 바꿀 수도 있어요:export default defineAppConfig({ ui: { inputMenu: { slots: { content: 'min-w-fit' } } } })
국가 선택기로 사용하기
InputMenu를 지연 로딩 방식의 국가 선택기로 사용할 수 있어요. 국가는 메뉴를 처음 열 때만 가져와요.
<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>
<UInputMenu
: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>
</UInputMenu>
</template>
[!NOTE]
이 예시는
immediate: false와 함께useLazyFetch를 사용해 메뉴를 처음 열 때만 국가를 불러와요.
API
Props
/**
* Props for the InputMenu component
*/
interface InputMenuProps {
/**
* The element or component this component should render as.
* @default 'div'
*/
as?: any;
id?: string | undefined;
/**
* @default 'text'
*/
type?: "number" | "search" | "color" | "button" | "checkbox" | "date" | "datetime-local" | "email" | "file" | "hidden" | "image" | "month" | "password" | "radio" | "range" | "reset" | "submit" | "tel" | "text" | "time" | "url" | "week" | string & {} | undefined;
/**
* The placeholder text when the input is empty.
*/
placeholder?: string | undefined;
/**
* @default 'primary'
*/
color?: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral" | undefined;
/**
* @default 'outline'
*/
variant?: "soft" | "outline" | "subtle" | "ghost" | "none" | undefined;
/**
* @default 'md'
*/
size?: "sm" | "md" | "xs" | "lg" | "xl" | undefined;
required?: boolean | undefined;
autofocus?: boolean | undefined;
/**
* @default 0
*/
autofocusDelay?: number | 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;
/**
* The icon displayed to delete a tag.
* Works only when `multiple` is `true`.
* @default appConfig.ui.icons.close
*/
deleteIcon?: 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, "as" | "asChild" | "forceMount"> & Partial<EmitsToProps<DismissableLayerEmits>> | undefined;
/**
* Display an arrow alongside the menu.
* `{ rounded: true }`{lang="ts-type"}
* @default false
*/
arrow?: boolean | Omit<ComboboxArrowProps, "as" | "asChild"> | 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 InputMenu when initially rendered. Use when you do not need to control the state of the InputMenu.
*/
defaultValue?: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod> | IsClearUsed<M, C> | undefined;
/**
* The controlled value of the InputMenu. 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;
/**
* The behavior of the InputMenu.
* - `combobox`: select one (or many) items from a list of suggestions.
* - `autocomplete`: free-form text input with optional suggestions. The `modelValue` becomes the input text (`string`) instead of a selected item.
* @default 'combobox'
*/
mode?: "autocomplete" | "combobox" | 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;
ui?: { root?: SlotClass; base?: SlotClass; leading?: SlotClass; leadingIcon?: SlotClass; leadingAvatar?: SlotClass; leadingAvatarSize?: SlotClass; trailing?: SlotClass; trailingIcon?: SlotClass; trailingClear?: 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; tagsItem?: SlotClass; tagsItemText?: SlotClass; tagsItemDelete?: SlotClass; tagsItemDeleteIcon?: SlotClass; tagsInput?: 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;
/**
* Whether to open the combobox when the input is clicked
* @default `false`
*/
openOnClick?: boolean | undefined;
/**
* Whether to open the combobox when the input is focused
* @default `false`
*/
openOnFocus?: 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;
enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
form?: string | undefined;
formaction?: string | undefined;
formenctype?: string | undefined;
formmethod?: string | undefined;
formnovalidate?: false | true | "true" | "false" | undefined;
formtarget?: string | undefined;
list?: string | undefined;
readonly?: false | true | "true" | "false" | undefined;
autocomplete?: string & {} | "on" | "off" | undefined;
/**
* @default ''
*/
searchTerm?: string | undefined;
}
[!NOTE] 참고: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attributes
이 컴포넌트는 네이티브
<input>HTML 속성도 모두 지원해요.
Slots
/**
* Slots for the InputMenu component
*/
interface InputMenuSlots {
leading(): any;
trailing(): any;
empty(): any;
item(): any;
item-leading(): any;
item-label(): any;
item-description(): any;
item-trailing(): any;
tags-item-text(): any;
tags-item-delete(): any;
content-top(): any;
content-bottom(): any;
create-item-label(): any;
}
Emits
/**
* Emitted events for the InputMenu component
*/
interface InputMenuEmits {
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;
remove-tag: (payload: [item: _Number<_Optional<_Nullable<GetModelValue<T, VK, M, ExcludeItem>, Mod>, Mod>, Mod> | IsClearUsed<M, C>]) => 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 |
|---|---|
inputRef |
Ref<HTMLInputElement | null> |
viewportRef |
Ref<HTMLDivElement | null> |
테마
export default defineAppConfig({
ui: {
inputMenu: {
slots: {
root: 'relative inline-flex items-center',
base: [
'rounded-md',
'transition-colors'
],
leading: 'absolute inset-y-0 start-0 flex items-center',
leadingIcon: 'shrink-0 text-dimmed',
leadingAvatar: 'shrink-0',
leadingAvatarSize: '',
trailing: 'group absolute inset-y-0 end-0 flex items-center disabled:cursor-not-allowed disabled:opacity-75 focus:outline-none',
trailingIcon: 'shrink-0 text-dimmed',
trailingClear: 'p-0',
arrow: 'fill-bg stroke-default',
content: 'max-h-[min(15rem,var(--reka-combobox-content-available-height,15rem))] w-(--reka-combobox-trigger-width) bg-default shadow-lg rounded-md ring ring-default overflow-hidden data-[state=open]:animate-[scale-in_100ms_var(--ease-out)] data-[state=closed]:animate-[scale-out_100ms_var(--ease-out)] origin-(--reka-combobox-content-transform-origin) pointer-events-auto flex flex-col',
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 gap-1.5 p-1.5 text-sm 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',
tagsItem: 'px-1.5 py-0.5 rounded-sm font-medium inline-flex items-center gap-0.5 ring ring-inset ring-accented bg-elevated text-default data-disabled:cursor-not-allowed data-disabled:opacity-75',
tagsItemText: 'truncate',
tagsItemDelete: [
'inline-flex items-center rounded-xs text-dimmed hover:text-default hover:bg-accented/75 disabled:pointer-events-none',
'transition-colors'
],
tagsItemDeleteIcon: 'shrink-0',
tagsInput: 'flex-1 border-0 bg-transparent placeholder:text-dimmed focus:outline-none disabled:cursor-not-allowed disabled:opacity-75'
},
variants: {
fieldGroup: {
horizontal: {
root: 'group has-focus-visible:z-[1]'
},
vertical: {
root: 'group has-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',
tagsItem: 'text-[10px]/3',
tagsItemDeleteIcon: 'size-3',
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',
tagsItem: 'text-[10px]/3',
tagsItemDeleteIcon: 'size-3',
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',
tagsItem: 'text-xs',
tagsItemDeleteIcon: 'size-3.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',
tagsItem: 'text-xs',
tagsItemDeleteIcon: 'size-3.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',
tagsItem: 'text-sm',
tagsItemDeleteIcon: 'size-4',
empty: 'p-3 text-base'
}
},
variant: {
outline: 'text-highlighted bg-default ring ring-inset ring-accented',
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',
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'
},
virtualize: {
true: {
viewport: 'p-1 isolate'
},
false: {
viewport: 'divide-y divide-default'
}
},
multiple: {
true: {
root: 'flex-wrap'
},
false: {
base: 'w-full border-0 placeholder:text-dimmed disabled:cursor-not-allowed disabled:opacity-75'
}
}
},
compoundVariants: [
{
multiple: false,
fieldGroup: 'horizontal',
class: {
base: 'group-not-only:group-first:rounded-e-none group-not-only:group-last:rounded-s-none group-not-last:group-not-first:rounded-none'
}
},
{
multiple: false,
fieldGroup: 'vertical',
class: {
base: 'group-not-only:group-first:rounded-b-none group-not-only:group-last:rounded-t-none group-not-last:group-not-first:rounded-none'
}
},
{
multiple: true,
fieldGroup: 'horizontal',
class: {
base: 'not-only:first:rounded-e-none not-only:last:rounded-s-none not-last:not-first:rounded-none focus-visible:z-[1]'
}
},
{
multiple: true,
fieldGroup: 'vertical',
class: {
base: 'not-only:first:rounded-b-none not-only:last:rounded-t-none not-last:not-first:rounded-none focus-visible:z-[1]'
}
},
{
variant: 'soft',
multiple: true,
class: 'has-focus:bg-elevated has-focus-visible:outline-3'
},
{
variant: 'ghost',
multiple: true,
class: 'has-focus:bg-elevated has-focus-visible:outline-3'
},
{
color: 'primary',
multiple: true,
variant: [
'outline',
'subtle'
],
class: 'has-focus-visible:outline-3 has-focus-visible:ring-primary'
},
{
color: 'secondary',
multiple: true,
variant: [
'outline',
'subtle'
],
class: 'has-focus-visible:outline-3 has-focus-visible:ring-secondary'
},
{
color: 'success',
multiple: true,
variant: [
'outline',
'subtle'
],
class: 'has-focus-visible:outline-3 has-focus-visible:ring-success'
},
{
color: 'info',
multiple: true,
variant: [
'outline',
'subtle'
],
class: 'has-focus-visible:outline-3 has-focus-visible:ring-info'
},
{
color: 'warning',
multiple: true,
variant: [
'outline',
'subtle'
],
class: 'has-focus-visible:outline-3 has-focus-visible:ring-warning'
},
{
color: 'error',
multiple: true,
variant: [
'outline',
'subtle'
],
class: 'has-focus-visible:outline-3 has-focus-visible:ring-error'
},
{
color: 'neutral',
multiple: true,
variant: [
'outline',
'subtle'
],
class: 'has-focus-visible:outline-3 has-focus-visible:ring-inverted'
},
{
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'
}
}
}
})
변경 기록
사이트맵
전체 페이지 목록은 사이트맵에서 확인할 수 있어요.