Listbox (리스트박스)
Listbox는 목록에 있는 항목들 중에서 하나 또는 여러 개의 값을 선택할 때 사용하는 컴포넌트예요. 단순한 선택 목록부터 필터, 그룹핑, 가상 스크롤까지 지원하는 선택 위젯이라고 보면 돼요.
출처: 문서
본문
가져오기 (Import)
import Listbox from 'primevue/listbox';
접근성 (Accessibility)
스크린 리더 관점에서 살펴볼게요. 컴포넌트를 설명하는 값은 aria-labelledby 또는 aria-label prop으로 제공할 수 있어요. 리스트 요소는 listbox 역할(role)을 가지며, 다중 선택이 활성화되면 aria-multiselectable 속성이 true로 설정돼요. 각 리스트 항목은 option 역할을 가지고 aria-selected와 aria-disabled를 속성으로 가져요. 필터링을 활성화했다면 filterInputProps를 정의해서 입력 요소에 aria-* 속성을 전달할 수 있고, filterPlaceholder도 스크린 리더가 주로 활용하는 값이에요.
키보드 지원은 이렇게 동작해요.
tab: 포커스를 가장 처음 선택된 옵션으로 옮겨요. 선택된 옵션이 없으면 첫 번째 옵션이 포커스를 받아요.up arrow: 이전 옵션으로 포커스를 옮겨요.down arrow: 다음 옵션으로 포커스를 옮겨요.enter: 포커스된 옵션의 선택 상태를 토글해요.space: 포커스된 옵션의 선택 상태를 토글해요.home: 첫 번째 옵션으로 포커스를 옮겨요.end: 마지막 옵션으로 포커스를 옮겨요.shift + down arrow: 다음 옵션으로 포커스를 옮기고 선택 상태를 토글해요.shift + up arrow: 이전 옵션으로 포커스를 옮기고 선택 상태를 토글해요.shift + space: 가장 최근에 선택한 옵션과 포커스된 옵션 사이의 항목들을 선택해요.control + shift + home: 포커스된 옵션과 첫 번째 옵션까지의 모든 옵션을 선택해요.control + shift + end: 포커스된 옵션과 마지막 옵션까지의 모든 옵션을 선택해요.control + a: 모든 옵션을 선택해요.pageUp: 시각 포커스를 첫 번째 옵션으로 점프시켜요.pageDown: 시각 포커스를 마지막 옵션으로 점프시켜요.아무 인쇄 가능 문자: 입력한 문자로 시작하는 라벨을 가진 옵션으로 포커스를 옮겨요.
필터 입력창의 키보드 지원은 이렇게 동작해요.
down arrow: 다음 옵션으로 포커스를 옮겨요. 다음 옵션이 없으면 시각 포커스는 그대로 유지돼요.up arrow: 이전 옵션으로 포커스를 옮겨요. 이전 옵션이 없으면 시각 포커스는 그대로 유지돼요.left arrow: 현재 옵션의 시각 포커스를 해제하고 입력 커서를 한 글자 왼쪽으로 옮겨요.right arrow: 현재 옵션의 시각 포커스를 해제하고 입력 커서를 한 글자 오른쪽으로 옮겨요.home: 입력 커서를 맨 끝으로 옮기고, 그렇지 않으면 첫 번째 옵션으로 포커스를 옮겨요.end: 입력 커서를 맨 앞으로 옮기고, 그렇지 않으면 마지막 옵션으로 포커스를 옮겨요.enter: 팝업을 닫고 멀티셀렉트 요소로 포커스를 옮겨요.escape: 팝업을 닫고 멀티셀렉트 요소로 포커스를 옮겨요.tab: 컴포넌트 안에서 다음 포커스 가능한 요소로 포커스를 옮겨요. 없으면 페이지의 다음 요소로 포커스를 옮겨요.
<span id="lb"></span>Options</span>
<Listbox aria-labelledby="lb" />
<Listbox aria-label="City" />
기본 (Basic)
Listbox는 options 컬렉션과 함께 v-model 속성으로 양방향 값 바인딩을 해요. 옵션의 라벨과 값은 각각 optionLabel과 optionValue 속성으로 정의해요. 참고로 옵션이 문자열 배열 같은 단순 원시 값이라면 optionLabel과 optionValue는 필요하지 않아요.
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" class="w-full md:w-56" />
체크마크 (Checkmark)
선택된 옵션을 강조하는 또 다른 방법으로, 하이라이트 대신 체크마크를 표시할 수도 있어요.
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" checkmark :highlightOnSelect="false" class="w-full md:w-56" />
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" checkmark :highlightOnSelect="false" class="w-full md:w-56" />
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedCity = ref();
const cities = ref([
{ name: 'New York', code: 'NY' },
{ name: 'Rome', code: 'RM' },
{ name: 'London', code: 'LDN' },
{ name: 'Istanbul', code: 'IST' },
{ name: 'Paris', code: 'PRS' }
]);
<\/script>
비활성화 (Disabled)
disabled가 있으면 요소를 편집하거나 포커스를 줄 수 없어요.
<Listbox v-model="selectedCity" disabled :options="cities" optionLabel="name" class="w-full md:w-56" />
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedCity" disabled :options="cities" optionLabel="name" class="w-full md:w-56" />
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedCity = ref();
const cities = ref([
{ name: 'New York', code: 'NY' },
{ name: 'Rome', code: 'RM' },
{ name: 'London', code: 'LDN' },
{ name: 'Istanbul', code: 'IST' },
{ name: 'Paris', code: 'PRS' }
]);
<\/script>
필터 (Filter)
Listbox는 내장 필터링을 제공해요. filter 속성을 추가하면 활성화돼요.
<Listbox v-model="selectedCity" :options="cities" filter optionLabel="name" class="w-full md:w-56" />
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedCity" :options="cities" filter optionLabel="name" class="w-full md:w-56" />
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedCity = ref();
const cities = ref([
{ name: 'New York', code: 'NY' },
{ name: 'Rome', code: 'RM' },
{ name: 'London', code: 'LDN' },
{ name: 'Istanbul', code: 'IST' },
{ name: 'Paris', code: 'PRS' }
]);
<\/script>
폼 (Forms)
Listbox는 PrimeVue Forms 라이브러리와 매끄럽게 통합돼요.
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4 w-full sm:w-56">
<div class="flex flex-col gap-1">
<Listbox name="city" :options="cities" optionLabel="name" fluid />
<Message v-if="$form.city?.invalid" severity="error" size="small" variant="simple">{{ $form.city.error?.message }}</Message>
</div>
<Button type="submit" severity="secondary" label="Submit" />
</Form>
Composition API 예제
<template>
<div class="card flex justify-center">
<Form v-slot="$form" :resolver="resolver" :initialValues="initialValues" @submit="onFormSubmit" class="flex flex-col gap-4 w-full sm:w-56">
<div class="flex flex-col gap-1">
<Listbox name="city" :options="cities" optionLabel="name" fluid />
<Message v-if="$form.city?.invalid" severity="error" size="small" variant="simple">{{ $form.city.error?.message }}</Message>
</div>
<Button type="submit" severity="secondary" label="Submit" />
</Form>
</div>
</template>
<script setup>
import { ref } from 'vue';
import { zodResolver } from '@primevue/forms/resolvers/zod';
import { useToast } from "primevue/usetoast";
import { z } from 'zod';
const toast = useToast();
const initialValues = ref({
city: { name: '' }
});
const resolver = ref(zodResolver(
z.object({
city: z.union([
z.object({
name: z.string().min(1, 'City is required.')
}),
z.any().refine((val) => false, { message: 'City is required.' })
])
})
));
const onFormSubmit = ({ valid }) => {
if (valid) {
toast.add({ severity: 'success', summary: 'Form is submitted.', life: 3000 });
}
};
<\/script>
그룹 (Group)
중첩된 데이터 구조를 제공하면 옵션을 그룹으로 묶을 수 있어요. 그룹의 라벨을 정의하려면 optionGroupLabel 속성이 필요하고, 그룹의 자식을 가리키는 속성을 정의하려면 optionGroupChildren도 필요해요.
<Listbox v-model="selectedCity" :options="groupedCities" optionLabel="label" optionGroupLabel="label" optionGroupChildren="items" class="w-full md:w-56" listStyle="max-height:250px">
<template #optiongroup="slotProps">
<div class="flex items-center">
<img :alt="slotProps.option.name" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()} mr-2\`" style="width: 18px" />
<div>{{ slotProps.option.label }}</div>
</div>
</template>
</Listbox>
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedCity" :options="groupedCities" optionLabel="label" optionGroupLabel="label" optionGroupChildren="items" class="w-full md:w-56" listStyle="max-height:250px">
<template #optiongroup="slotProps">
<div class="flex items-center">
<img :alt="slotProps.option.name" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()} mr-2\`" style="width: 18px" />
<div>{{ slotProps.option.label }}</div>
</div>
</template>
</Listbox>
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedCity = ref();
const groupedCities = ref([
{
label: 'Germany',
code: 'DE',
items: [
{ label: 'Berlin', value: 'Berlin' },
{ label: 'Frankfurt', value: 'Frankfurt' },
{ label: 'Hamburg', value: 'Hamburg' },
{ label: 'Munich', value: 'Munich' }
]
},
{
label: 'USA',
code: 'US',
items: [
{ label: 'Chicago', value: 'Chicago' },
{ label: 'Los Angeles', value: 'Los Angeles' },
{ label: 'New York', value: 'New York' },
{ label: 'San Francisco', value: 'San Francisco' }
]
},
{
label: 'Japan',
code: 'JP',
items: [
{ label: 'Kyoto', value: 'Kyoto' },
{ label: 'Osaka', value: 'Osaka' },
{ label: 'Tokyo', value: 'Tokyo' },
{ label: 'Yokohama', value: 'Yokohama' }
]
}
]);
<\/script>
유효하지 않은 상태 (Invalid)
유효성 검사 실패를 나타낼 때는 invalid prop으로 invalid 상태를 표시해요. 폼 유효성 검사 라이브러리와 통합할 때 이 스타일을 사용할 수 있어요.
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" :invalid="selectedCity === null" class="w-full md:w-56" />
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedCity" :options="cities" optionLabel="name" :invalid="selectedCity === null" class="w-full md:w-56" />
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedCity = ref();
const cities = ref([
{ name: 'New York', code: 'NY' },
{ name: 'Rome', code: 'RM' },
{ name: 'London', code: 'LDN' },
{ name: 'Istanbul', code: 'IST' },
{ name: 'Paris', code: 'PRS' }
]);
<\/script>
다중 선택 (Multiple)
Listbox는 기본적으로 하나의 항목만 고를 수 있어요. 여러 개를 선택하려면 multiple 속성을 활성화하세요. 선택적인 metaKeySelection이 있으면 동작이 바뀌어서, 새 항목을 선택할 때 meta 키를 누르고 있어야 해요.
<Listbox v-model="selectedCity" :options="cities" multiple optionLabel="name" class="w-full md:w-56" />
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedCity" :options="cities" multiple optionLabel="name" class="w-full md:w-56" />
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedCity = ref();
const cities = ref([
{ name: 'New York', code: 'NY' },
{ name: 'Rome', code: 'RM' },
{ name: 'London', code: 'LDN' },
{ name: 'Istanbul', code: 'IST' },
{ name: 'Paris', code: 'PRS' }
]);
<\/script>
템플릿 (Template)
옵션의 커스텀 콘텐츠는 option을 매개변수로 받는 option 슬롯으로 표시해요. 그 밖에 사용할 수 있는 템플릿 섹션은 filter와 optionGroup이에요.
<Listbox v-model="selectedCountry" :options="countries" optionLabel="name" class="w-full md:w-56" listStyle="max-height:250px">
<template #option="slotProps">
<div class="flex items-center">
<img :alt="slotProps.option.name" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()} mr-2\`" style="width: 18px" />
<div>{{ slotProps.option.name }}</div>
</div>
</template>
</Listbox>
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedCountry" :options="countries" optionLabel="name" class="w-full md:w-56" listStyle="max-height:250px">
<template #option="slotProps">
<div class="flex items-center">
<img :alt="slotProps.option.name" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="\`flag flag-\${slotProps.option.code.toLowerCase()} mr-2\`" style="width: 18px" />
<div>{{ slotProps.option.name }}</div>
</div>
</template>
</Listbox>
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedCountry = ref();
const countries = ref([
{ name: 'Australia', code: 'AU' },
{ name: 'Brazil', code: 'BR' },
{ name: 'China', code: 'CN' },
{ name: 'Egypt', code: 'EG' },
{ name: 'France', code: 'FR' },
{ name: 'Germany', code: 'DE' },
{ name: 'India', code: 'IN' },
{ name: 'Japan', code: 'JP' },
{ name: 'Spain', code: 'ES' },
{ name: 'United States', code: 'US' }
]);
<\/script>
가상 스크롤 (Virtual Scroll)
VirtualScroller를 사용하면 이 데모의 10만 개 레코드처럼 긴 옵션 목록도 효율적으로 렌더링할 수 있어요. 설정은 virtualScrollerOptions 속성으로 하고, Listbox가 내부적으로 VirtualScroller를 사용하기 때문에 사용 가능한 옵션에 대한 자세한 내용은 VirtualScroller 문서를 참고하세요.
<Listbox v-model="selectedItem" :options="items" optionLabel="label" optionValue="value" :virtualScrollerOptions="{ itemSize: 38 }" class="w-full md:w-56" listStyle="height:250px" striped />
Composition API 예제
<template>
<div class="card flex justify-center">
<Listbox v-model="selectedItem" :options="items" optionLabel="label" optionValue="value"
:virtualScrollerOptions="{ itemSize: 38 }" class="w-full md:w-56" listStyle="height:250px" striped />
</div>
</template>
<script setup>
import { ref } from "vue";
const selectedItem = ref();
const items = ref(Array.from({ length: 100000 }, (_, i) => ({ label: \`Item #\${i}\`, value: i })));
<\/script>
Listbox
Props (속성)
| 이름 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| modelValue | any | - | 컴포넌트의 값이에요. |
| defaultValue | any | - | modelValue로 제어하지 않을 때 입력의 기본값이에요. |
| name | string | - | 폼 제출 시 주로 사용되는 요소의 name 속성이에요. |
| options | any[] | - | 사용 가능한 옵션으로 표시할 selectitem 배열이에요. |
| optionLabel | string | Function | - | 옵션의 라벨로 사용할 속성 이름 또는 getter 함수예요. |
| optionValue | string | Function | - | 옵션의 값으로 사용할 속성 이름 또는 getter 함수예요. 정의하지 않으면 옵션 자체가 기본값이 돼요. |
| optionDisabled | string | Function | - | 옵션의 disabled 플래그로 사용할 속성 이름 또는 getter 함수예요. 정의하지 않으면 false가 기본값이에요. |
| optionGroupLabel | string | Function | - | 옵션 그룹의 라벨로 사용할 속성 이름 또는 getter 함수예요. |
| optionGroupChildren | string | Function | - | 옵션 그룹의 자식 옵션을 가리키는 속성 이름 또는 getter 함수예요. |
| listStyle | string | - | 내부 리스트 요소의 인라인 스타일이에요. |
| scrollHeight | string | 14rem | 뷰포트의 높이예요. 목록 높이가 이 값을 넘으면 스크롤바가 생겨요. |
| invalid | boolean | false | 설정하면 컴포넌트에 invalid 상태 스타일이 적용돼요. |
| disabled | boolean | false | 설정하면 컴포넌트가 비활성화돼요. |
| fluid | boolean | null | 활성화하면 컨테이너 너비의 100%를 차지해요. |
| dataKey | string | - | 옵션을 고유하게 식별하는 속성이에요. |
| multiple | boolean | false | 설정하면 여러 값을 선택할 수 있어요. |
| metaKeySelection | boolean | false | 여러 항목을 선택하는 방식을 정의해요. true이면 항목을 선택하거나 해제할 때 meta 키를 눌러야 하고, false이면 각 항목을 개별적으로 토글할 수 있어요. 터치 지원 기기에서는 metaKeySelection이 자동으로 꺼져요. |
| filter | boolean | false | 설정하면 헤더에 필터 입력창을 표시해요. |
| filterPlaceholder | string | - | 필터 입력창이 비어 있을 때 표시할 플레이스홀더 텍스트예요. |
| filterLocale | string | - | 필터링에 사용할 로케일이에요. 기본 로케일은 호스트 환경의 현재 로케일이에요. |
| filterMatchMode | HintedString<"startsWith" | "contains" | "endsWith"> | contains | 옵션을 검색할 때 사용할 필터링 알고리즘을 정의해요. |
| filterFields | string[] | - | 옵션을 필터링할 때 사용하는 필드예요. 기본값은 optionLabel이에요. |
| virtualScrollerOptions | any | - | virtualScroller 기능 사용 여부예요. VirtualScroller 컴포넌트의 속성을 객체 형태로 그대로 사용할 수 있어요. |
| autoOptionFocus | boolean | false | 첫 번째로 보이는 요소나 선택된 요소에 포커스를 둘지 여부예요. |
| selectOnFocus | boolean | false | 활성화하면 포커스된 옵션이 선택돼요. |
| focusOnHover | boolean | true | 활성화하면 마우스를 올린 옵션에 포커스가 놓여요. |
| highlightOnSelect | boolean | true | 선택된 옵션에 highlight 클래스를 추가할지 여부예요. |
| checkmark | boolean | false | 선택된 옵션을 체크 표시와 함께 보여줄지 여부예요. |
| filterMessage | string | '{0} results are available' | 필터링 결과가 있을 때 숨겨진 접근성 필드에 표시할 텍스트예요. 기본값은 PrimeVue 로케일 설정의 값이에요. |
| selectionMessage | string | '{0} items selected' | 옵션을 선택했을 때 숨겨진 접근성 필드에 표시할 텍스트예요. 기본값은 PrimeVue 로케일 설정의 값이에요. |
| emptySelectionMessage | string | No selected item | 아무 옵션도 선택하지 않았을 때 숨겨진 접근성 필드에 표시할 텍스트예요. 기본값은 PrimeVue 로케일 설정의 값이에요. |
| emptyFilterMessage | string | No results found | 필터링 결과가 없을 때 표시할 텍스트예요. 기본값은 PrimeVue 로케일 설정의 값이에요. |
| emptyMessage | string | No available options | 사용 가능한 옵션이 없을 때 표시할 텍스트예요. 기본값은 PrimeVue 로케일 설정의 값이에요. |
| striped | boolean | false | 행을 교대로 다른 색으로 표시할지 여부예요. |
| tabindex | string | number | - | 탭 순서에서 요소의 인덱스예요. |
| filterIcon | string | - | 필터 입력창에 표시할 아이콘이에요. |
| ariaLabel | string | - | 인터랙티브 요소에 라벨을 붙이는 문자열 값을 정의해요. |
| ariaLabelledby | string | - | 내부 입력 요소의 식별자예요. |
| formControl | Record<string, any> | - | 폼 컨트롤 객체예요. 주로 유효성 검사와 폼 상태를 다룰 때 사용해요. |
| dt | any | - | 디자인 토큰으로 컴포넌트 전용 스코프 CSS 변수를 만들어요. |
| pt | PassThrough<ListboxPassThroughOptions> | - | 컴포넌트 내부 DOM 요소에 속성을 전달할 때 사용해요. |
| ptOptions | any | - | 컴포넌트의 passthrough(pt) 옵션을 구성할 때 사용해요. |
| unstyled | boolean | false | 활성화하면 코어에서 컴포넌트 관련 스타일을 제거해요. |
Pass Through Options (패스 스루 옵션)
| 이름 | 타입 | 설명 |
|---|---|---|
| root | ListboxPassThroughOptionType | 루트의 DOM 요소에 속성을 전달할 때 사용해요. |
| header | ListboxPassThroughOptionType | 헤더의 DOM 요소에 속성을 전달할 때 사용해요. |
| pcFilterContainer | any | IconField 컴포넌트에 속성을 전달할 때 사용해요. |
| pcFilter | any | InputText 컴포넌트에 속성을 전달할 때 사용해요. |
| pcFilterIconContainer | any | InputIcon 컴포넌트에 속성을 전달할 때 사용해요. |
| filterIcon | ListboxPassThroughOptionType | 필터 아이콘의 DOM 요소에 속성을 전달할 때 사용해요. |
| listContainer | ListboxPassThroughOptionType | 리스트 컨테이너의 DOM 요소에 속성을 전달할 때 사용해요. |
| virtualScroller | any | VirtualScroller 컴포넌트에 속성을 전달할 때 사용해요. |
| list | ListboxPassThroughOptionType | 리스트의 DOM 요소에 속성을 전달할 때 사용해요. |
| optionGroup | ListboxPassThroughOptionType | 옵션 그룹의 DOM 요소에 속성을 전달할 때 사용해요. |
| option | ListboxPassThroughOptionType | 옵션의 DOM 요소에 속성을 전달할 때 사용해요. |
| optionCheckIcon | ListboxPassThroughOptionType | 옵션 체크 아이콘의 DOM 요소에 속성을 전달할 때 사용해요. |
| optionBlankIcon | ListboxPassThroughOptionType | 옵션 빈 아이콘의 DOM 요소에 속성을 전달할 때 사용해요. |
| emptyMessage | ListboxPassThroughOptionType | emptyMessage의 DOM 요소에 속성을 전달할 때 사용해요. |
| hiddenFirstFocusableEl | ListboxPassThroughOptionType | 숨겨진 첫 포커스 가능 요소의 DOM 요소에 속성을 전달할 때 사용해요. |
| hiddenFilterResult | ListboxPassThroughOptionType | 숨겨진 필터 결과의 DOM 요소에 속성을 전달할 때 사용해요. |
| hiddenSelectedMessage | ListboxPassThroughOptionType | 숨겨진 선택 메시지의 DOM 요소에 속성을 전달할 때 사용해요. |
| hiddenLastFocusableEl | ListboxPassThroughOptionType | 숨겨진 마지막 포커스 가능 요소의 DOM 요소에 속성을 전달할 때 사용해요. |
| hooks | any | 모든 라이프사이클 훅을 관리할 때 사용해요. |
Theming (테마)
CSS Classes (CSS 클래스)
| 클래스 | 설명 |
|---|---|
| p-listbox | 루트 요소의 클래스 이름이에요. |
| p-listbox-header | 헤더 요소의 클래스 이름이에요. |
| p-listbox-filter | 필터 요소의 클래스 이름이에요. |
| p-listbox-list-container | 리스트 컨테이너 요소의 클래스 이름이에요. |
| p-listbox-list | 리스트 요소의 클래스 이름이에요. |
| p-listbox-option-group | 옵션 그룹 요소의 클래스 이름이에요. |
| p-listbox-option | 옵션 요소의 클래스 이름이에요. |
| p-listbox-option-check-icon | 옵션 체크 아이콘 요소의 클래스 이름이에요. |
| p-listbox-option-blank-icon | 옵션 빈 아이콘 요소의 클래스 이름이에요. |
| p-listbox-empty-message | 빈 메시지 요소의 클래스 이름이에요. |
Design Tokens (디자인 토큰)
| 토큰 | CSS 변수 | 설명 |
|---|---|---|
| listbox.background | --p-listbox-background | 루트의 배경 |
| listbox.disabled.background | --p-listbox-disabled-background | 루트의 비활성 배경 |
| listbox.border.color | --p-listbox-border-color | 루트의 테두리 색 |
| listbox.invalid.border.color | --p-listbox-invalid-border-color | 루트의 invalid 테두리 색 |
| listbox.color | --p-listbox-color | 루트의 색 |
| listbox.disabled.color | --p-listbox-disabled-color | 루트의 비활성 색 |
| listbox.shadow | --p-listbox-shadow | 루트의 그림자 |
| listbox.border.radius | --p-listbox-border-radius | 루트의 테두리 반경 |
| listbox.transition.duration | --p-listbox-transition-duration | 루트의 전환 시간 |
| listbox.list.padding | --p-listbox-list-padding | 리스트의 패딩 |
| listbox.list.gap | --p-listbox-list-gap | 리스트의 간격 |
| listbox.list.header.padding | --p-listbox-list-header-padding | 리스트의 헤더 패딩 |
| listbox.option.focus.background | --p-listbox-option-focus-background | 옵션의 포커스 배경 |
| listbox.option.selected.background | --p-listbox-option-selected-background | 옵션의 선택 배경 |
| listbox.option.selected.focus.background | --p-listbox-option-selected-focus-background | 옵션의 선택+포커스 배경 |
| listbox.option.color | --p-listbox-option-color | 옵션의 색 |
| listbox.option.focus.color | --p-listbox-option-focus-color | 옵션의 포커스 색 |
| listbox.option.selected.color | --p-listbox-option-selected-color | 옵션의 선택 색 |
| listbox.option.selected.focus.color | --p-listbox-option-selected-focus-color | 옵션의 선택+포커스 색 |
| listbox.option.padding | --p-listbox-option-padding | 옵션의 패딩 |
| listbox.option.border.radius | --p-listbox-option-border-radius | 옵션의 테두리 반경 |
| listbox.option.striped.background | --p-listbox-option-striped-background | 옵션의 스트라이프 배경 |
| listbox.option.group.background | --p-listbox-option-group-background | 옵션 그룹의 배경 |
| listbox.option.group.color | --p-listbox-option-group-color | 옵션 그룹의 색 |
| listbox.option.group.font.weight | --p-listbox-option-group-font-weight | 옵션 그룹의 글자 두께 |
| listbox.option.group.padding | --p-listbox-option-group-padding | 옵션 그룹의 패딩 |
| listbox.checkmark.color | --p-listbox-checkmark-color | 체크마크의 색 |
| listbox.checkmark.gutter.start | --p-listbox-checkmark-gutter-start | 체크마크의 거터 시작 |
| listbox.checkmark.gutter.end | --p-listbox-checkmark-gutter-end | 체크마크의 거터 끝 |
| listbox.empty.message.padding | --p-listbox-empty-message-padding | 빈 메시지의 패딩 |
더 알아보기 (Learn more)
optionLabel과 optionValue로 데이터를 연결하고, filter나 multiple 같은 속성으로 동작을 확장하는 방식이 Listbox 사용의 핵심이에요. 긴 목록이 필요하면 virtualScrollerOptions를 활용하는 것도 잊지 마세요. 나머지 옵션은 위 표와 PrimeVue 공식 문서의 Listbox 섹션을 참고하세요.