Select
Select는 목록을 펼쳐 값을 고르는 폼 입력 요소입니다. 주로 지역, 분류, 담당자처럼 정해진 선택지 가운데 값을 입력받을 때 사용됩니다. 여러 개를 고르거나 글자를 입력해 목록을 좁힐 수 있고, 라벨과 오류 문구를 함께 표시할 수 있습니다.
State
Code
vue
<script setup>
import { ref } from 'vue'
import { ASelect } from '@mobigen/rnd-design-system'
const value = ref('')
</script>
<template>
<ASelect v-model="value" label="Default" placeholder="옵션을 선택하세요" :options="['Apple', 'Banana', 'Cherry']" />
</template>여러 개를 고르고 검색하는 형태:
vue
<script setup>
import { ref } from 'vue'
import { ASelect } from '@mobigen/rnd-design-system'
const cities = ref([])
</script>
<template>
<ASelect v-model="cities" multiple searchable label="도시" placeholder="도시를 선택하세요" :options="['서울', '부산', '대구']" />
</template>Props
| 속성 | 값 |
|---|---|
modelValue | String, Array |
multiple | true, false |
searchable | true, false |
emptyText | String |
removeLabel | String |
label | String |
ariaLabel | String |
id | String |
placeholder | String |
options | Array (string[] 또는 { value, label, disabled }[]) |
disabled | true, false |
error | String |
hint | String |
required | true, false |
size | sm, md, lg, xl |
Events
| 이벤트 | 전달 값 |
|---|---|
update:modelValue | String, Array |
Methods
| 이름 | 설명 |
|---|---|
focus() | 트리거 버튼에 포커스를 준다. 템플릿 ref로 호출한다. |
Notes
- 폼 제출과 브라우저의 필수 검증은 화면에 보이지 않는
<select>(aria-hidden,tabindex="-1")가 맡는다.name을 주면 선택된 값이 그 이름으로 제출된다. - 값 배열은 고른 순서가 아니라
options의 순서를 따른다. 목록에aria-multiselectable이 붙는다. - 값은 문자열(또는 문자열 배열)로만 전달된다. 숫자 값 옵션을 그대로 쓸 수 없다.