Command
Command는 검색어를 입력하면 일치하는 명령이나 항목만 남겨 보여 주는 검색 목록입니다. 주로 단축키로 여는 빠른 실행 창이나 메뉴가 많은 화면의 항목 찾기에 사용됩니다. 메뉴를 하나씩 찾아 들어가지 않고도 원하는 기능으로 바로 이동할 수 있게 합니다.
State
Code
vue
<script setup>
import { ref } from 'vue'
import { ACommand } from '@mobigen/rnd-design-system'
const commandRef = ref(null)
const items = [
{ label: '새 문서 만들기', hint: '동작' },
{ label: '검색 결과 내보내기', hint: '동작' },
{ label: '설정', hint: '이동', disabled: true }
]
function onSelect(item) {
// item은 items의 원소
}
</script>
<template>
<ACommand
ref="commandRef"
group-label="필터를 고르거나 파일명을 입력하세요"
placeholder="명령 또는 파일 검색…"
:items="items"
width="420px"
:limit="10"
@select="onSelect"
/>
</template>Props
| 속성 | 값 |
|---|---|
placeholder | String |
groupLabel | String |
items | Array ({ label, hint, disabled, icon }[]) (필수) |
width | String |
limit | Number |
emptyText | String |
ariaLabel | String |
maxHeight | String |
Events
| 이벤트 | 전달 값 |
|---|---|
select | 선택된 항목 객체 |
Slots
| 슬롯 | 전달 값 |
|---|---|
item | { item, active } |
Methods
| 이름 | 설명 |
|---|---|
focus() | 입력창에 포커스를 준다. |
reset() | 검색어를 비우고 강조 위치를 첫 활성 항목으로 되돌린다. |
Notes
- 항목의
key로label을 쓴다.label이 중복되면 안 된다. 검색도label만 대상으로 한다.