Search 검색 상자
검색 상자: input 의 검색 시맨틱 셸(형태 + 제출 키 + 취소). 디바운스 트리거 (창 내 여러 입력을 하나의 update:modelValue 로 병합), 클래스명과 지우기 버튼 표시 여부는 모두 @lh-ui/share/core/search 의 순수 로직을 소비합니다; 입력은 네이티브 input (confirm-type="search", @confirm 을 search 이벤트에 매핑)입니다.
플랫폼 차이(등록): 제출 키는 네이티브 input 의
confirm-type="search"+@confirm이 담당(web 삼단은 Enter 키); 읽기 전용 / 비활성 상태에서는 지우기 버튼도 숨김(순수 함수 파생으로 일치).
기본 사용법
vue
<template>
<lh-search
v-model="value"
placeholder="키워드를 입력하세요"
aria-label="상품 검색"
@search="onSearch"
@clear="onClear"
/>
<text>현재 값: {{ value || '(비어 있음)' }}|제출 {{ times }}회</text>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const value = ref('')
const times = ref(0)
function onSearch(v: string) {
times.value += 1
}
function onClear() {
value.value = ''
}
</script>각진 형태와 취소 버튼
vue
<lh-search v-model="value" shape="square" cancel-text="취소" @cancel="onCancel" />cancelText 에 비어 있지 않은 문자열을 전달한 경우에만 취소 버튼을 렌더링합니다(클릭 시 cancel 이벤트 발생).
비활성화와 읽기 전용
vue
<lh-search model-value="고정" disabled />
<lh-search model-value="읽기 전용" readonly />Props
| 이름 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| modelValue | 검색 키워드(제어, v-model) | string | '' |
| placeholder | 자리표시 텍스트 | string | '' |
| shape | 형태 | "round" | "square" | 'round' |
| clearable | 값이 있을 때 지우기 버튼 표시 | boolean | true |
| disabled | 비활성화 | boolean | false |
| readonly | 읽기 전용(포커스 가능하지만 편집 불가) | boolean | false |
| maxLength | 최대 입력 길이 | number | — |
| cancelText | 취소 버튼 텍스트(비어 있으면 렌더링하지 않음) | string | — |
| ariaLabel | 접근 가능한 이름(placeholder / 값으로 대체) | string | — |
| customClass | 커스텀 클래스(루트 노드로 전달) | string | — |
| sx | 빠른 레이아웃 props | LhSxProps | — |
Events
| 이벤트 | 설명 | 페이로드 |
|---|---|---|
| update:modelValue | 키워드 변경(디바운스; v-model 쓰기 경로) | value: string |
| search | 검색 제출(네이티브 input confirm-type=search) | value: string |
| cancel | 취소 버튼 클릭 | — |
| clear | 지우기 버튼 클릭(빈 문자열을 쓰기) | — |
| focus | 포커스 | — |
| blur | 블러(대기 중인 디바운스 값 플러시) | — |
접근성
루트의 aria-label 은 ariaLabel > placeholder > 값 순으로 대체됩니다; 지우기 버튼은 자체 aria-label="清除" 를 가집니다.

