본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Select

원문 보기 위키 갱신

Select는 여러 옵션 가운데 하나 또는 여러 값을 선택하게 해 주는 컴포넌트예요. 필터링, 태그 생성, 원격 옵션 로딩까지 지원해서 단순 드롭다운을 넘어서는 요구도 처리할 수 있죠. 옵션 구조도 커스텀 필드 이름으로 유연하게 맞출 수 있어요.

출처: 문서

본문

선택해 보세요!

Demo

basic.vue
size.vue
multiple.vue
events.vue
filterable.vue
tag.vue
menu-width.vue
remote.vue
remote-multiple.vue
clearable.vue
scroll-event.vue
group.vue
many-options.vue
custom-option.vue
custom-suffix.vue
action.vue
fallback-option.vue
max-tag-count.vue
add-tooltip.vue
render-tag.vue
focus.vue
render-person.vue
tag-input.vue
custom-field.vue

API

Select Props

이름 타입 기본값 설명 버전
consistent-menu-width boolean true 메뉴 너비를 select 트리거 요소와 같게 유지할지 여부예요. false로 설정하면 virtual-scroll도 함께 꺼져요.
children-field string 'children' 그룹 옵션 children의 필드 이름이에요. 2.29.1
clearable boolean false 값을 지울 수 있는지 여부예요.
clear-created-options-on-clear boolean true tag와 clearable이 켜져 있을 때, 지우기 동작에서 생성된 옵션까지 지울지 여부예요. 2.44.0
clear-filter-after-select boolean true multiple과 filter가 켜져 있을 때, 옵션을 선택한 뒤 필터 키워드를 지울지 여부예요. 2.25.2
default-value Array<string | number> | string | number | null null 기본값이에요.
disabled boolean false select를 비활성화할지 여부예요.
ellipsis-tag-popover-props PopoverProps undefined 생략(ellipsis) 태그 미리보기 popover의 props예요. 2.37.0
fallback-option false | (value: string | number) => SelectOption value => ({ label: '' + value, value }) 대응하는 옵션이 없는 값으로 만들어 표시할 옵션이에요. false로 설정하면 fallback 옵션을 만들지 않고 보여 주지도 않아요.
filterable boolean false 옵션을 필터링할 수 있는지 여부예요.
filter (pattern: string, option: Object) => boolean 문자열 검색 방식. 필터 함수예요.
ignore-composition boolean true IME 조합(composition) 상태를 무시해요. 기본으로 조합 중에는 input 이벤트가 filter를 트리거하지 않아요. 2.33.4
input-props InputHTMLAttributes undefined 트리거 안 input 요소의 속성이에요. select가 filterable일 때만 동작해요.
keyboard boolean true 키보드 제어를 허용할지 여부예요. 2.34.4
label-field string 'label' 옵션 label의 필드 이름이에요. 2.29.1
loading boolean false 로딩 상태를 표시할지 여부예요.
max-tag-count number | 'responsive' undefined multiple 모드에서 표시할 선택 값의 최대 개수예요. responsive를 쓰면 모든 태그가 한 줄에 들어가요.
menu-props HTMLAttributes undefined 메뉴의 DOM props예요.
menu-size 'tiny' | 'small' | 'medium' | 'large' 'medium' select 메뉴의 크기예요. 2.40.0
multiple boolean false 여러 값을 선택할 수 있게 할지 여부예요.
node-props (option: SelectOption | SelectGroupOption) => object undefined 옵션의 DOM 속성을 만들어 주는 함수예요. 2.32.2
options Array<SelectOption | SelectGroupOption> [] 선택할 수 있는 옵션이에요. 자세한 내용은 아래 SelectOption Properties를 참고하세요.
placeholder string 'Please Select' (i18n) 플레이스홀더예요.
placement 'top-start' | 'top' | 'top-end' | 'right-start' | 'right' | 'right-end' | 'bottom-start' | 'bottom' | 'bottom-end' | 'left-start' | 'left' | 'left-end' 'bottom-start' 옵션 메뉴의 위치예요. 2.25.0
remote boolean false 옵션을 비동기로 가져올 수 있게 해 줘요. remote를 설정하면 filter와 tag가 options에 동작하지 않는다는 점에 주의하세요.
render-label (option: SelectOption | SelectGroupOption, selected: boolean) => VNodeChild undefined 각 옵션 label의 렌더 함수예요.
render-option (info: { node: VNode, option: SelectOption | SelectGroupOption, selected: boolean }) => VNodeChild undefined 각 옵션의 렌더 함수예요.
render-tag (props: { option: SelectBaseOption, handleClose: () => void }) => VNodeChild undefined 각 옵션 태그의 렌더 함수예요.
reset-menu-on-options-change boolean true options가 바뀔 때 메뉴 상태(예: 스크롤 상태)를 초기화할지 여부예요. 2.24.2
scrollbar-props ScrollbarProps undefined Scrollbar props를 참고하세요. 2.44.0
show boolean undefined 옵션 메뉴를 표시/열지 여부예요.
show-arrow boolean true 드롭다운 화살표를 표시할지 여부예요.
show-checkmark boolean true 체크 표시를 보여 줄지 여부예요. 2.33.4
show-on-focus boolean false 포커스를 받을 때 메뉴를 열지 여부예요. 2.34.3
size 'tiny' | 'small' | 'medium' | 'large' 'medium' select 입력의 크기예요.
status 'success' | 'warning' | 'error' undefined 검증 상태예요. 2.27.0
tag boolean false 사용자가 새 옵션을 만들 수 있는지 여부예요. filterable과 함께 써야 해요.
to string | HTMLElement | false body 메뉴의 컨테이너 노드예요. false로 설정하면 분리(detach)하지 않아요.
value Array<string | number> | string | number | null undefined 직접 설정했을 때의 값이에요.
value-field string 'value' 옵션 value의 필드 이름이에요. 2.29.1
virtual-scroll boolean true 가상 스크롤을 사용할지 여부예요.
on-blur () => void undefined 선택 요소가 블러될 때 호출되는 콜백이에요.
on-clear () => void undefined 선택 요소가 지워질 때 호출되는 콜백이에요.
on-create (label: string) => SelectOption label => ({ label, value: label }) 커스텀 옵션을 입력했을 때 옵션을 만드는 방식이에요. filter는 만들어진 옵션에도 적용돼요. 만들어진 옵션의 value가 다른 옵션과 겹치지 않게 하는 게 좋아요. tag prop과 함께 쓰세요.
on-focus () => void undefined 선택 요소가 포커스를 받을 때 호출되는 콜백이에요.
on-scroll (e: ScrollEvent) => void undefined 옵션 메뉴가 스크롤될 때 호출되는 콜백이에요.
on-search (value: string) => void undefined 검색이 수행될 때 호출되는 콜백이에요.
on-update:show (show: boolean) => void undefined 메뉴 열림 상태가 바뀔 때의 콜백이에요. 2.24.2
on-update:value (value: Array | string | number | null, option: SelectBaseOption | null | SelectBaseOption[]) => void undefined 선택 값이 갱신될 때 호출되는 콜백이에요.

SelectOption Properties

이름 타입 설명
class string 옵션의 클래스를 커스터마이즈해요.
disabled boolean 옵션을 비활성화할지 여부예요.
label string | ((option: SelectOption, selected: boolean) => VNodeChild) 옵션의 라벨이에요. render 함수를 쓰면 기본 필터가 그 옵션을 필터링한다는 점에 주의하세요.
render (info: { node: VNode, option: SelectOption, selected: boolean }) => VNodeChild 옵션 전체를 렌더해요.
style string | CSSProperties 옵션의 스타일을 커스터마이즈해요.
value string | number 각 옵션마다 고유해야 해요.

SelectGroupOption Properties

이름 타입 설명
children Array<SelectOption> 자식 select 옵션이에요.
label string | ((option: SelectGroupOption) => VNodeChild) 그룹의 라벨이에요.
key string | number 각 옵션마다 고유해야 해요.
render (info: { node: VNode, option: SelectOption, selected: boolean }) => VNodeChild 옵션 전체를 렌더해요.
type 'group' 그룹 옵션의 타입이에요.

Select Slots

이름 파라미터 설명 버전
header () 헤더 메뉴 슬롯이에요. 2.37.0
action () 옵션 메뉴 슬롯이에요.
empty () 옵션 메뉴의 빈 상태 슬롯이에요.
arrow () 화살표 아이콘 슬롯이에요. 2.24.2

Select Methods

이름 타입 설명 버전
focus () => void 포커스를 줘요. 2.24.2
focusInput () => void 입력에 포커스를 줘요. 2.35.0
blur () => void 블러해요. 2.24.2
blurInput () => void 입력을 블러해요. 2.35.0

더 알아보기 (Learn more)

옵션 데이터 구조가 라이브러리 기본 필드 이름과 다르면 label-field, value-field, children-field로 맞출 수 있어요. 많은 옵션을 다룰 때는 가상 스크롤 동작과 consistent-menu-width가 끄는 영향도 함께 확인해 보세요.