Search
Search box: a search-semantic shell over input (shape + submit key + cancel). The debounce trigger (multiple inputs within the window merge into one update:modelValue), class names and clear-button visibility are all pure logic consumed from @lh-ui/share/core/search; the input is a native input (confirm-type="search", @confirm mapped to the search event).
Platform difference (registered): the submit key is handled by the native input's
confirm-type="search"+@confirm(web uses the Enter key); the clear button is likewise hidden in readonly / disabled states (derived by the same pure functions).
Basic usage
<template>
<lh-search
v-model="value"
placeholder="Enter a keyword"
aria-label="Search products"
@search="onSearch"
@clear="onClear"
/>
<text>Current: {{ value || '(empty)' }}|Submitted {{ times }} 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>Square shape and cancel button
<lh-search v-model="value" shape="square" cancel-text="Cancel" @cancel="onCancel" />The cancel button is rendered only when cancelText is a non-empty string (clicking it fires the cancel event).
Disabled and readonly
<lh-search model-value="fixed" disabled />
<lh-search model-value="readonly" readonly />Props
| Name | Description | Type | Default |
|---|---|---|---|
| modelValue | Search keyword (controlled, v-model) | string | '' |
| placeholder | Placeholder text | string | '' |
| shape | Shape | "round" | "square" | 'round' |
| clearable | Show the clear button when there is a value | boolean | true |
| disabled | Disabled | boolean | false |
| readonly | Readonly (focusable but not editable) | boolean | false |
| maxLength | Max input length | number | — |
| cancelText | Cancel button text (not rendered when empty) | string | — |
| ariaLabel | Accessible name (falls back to placeholder / value) | string | — |
| customClass | Custom class (forwarded to the root node) | string | — |
| sx | Quick layout props | LhSxProps | — |
Events
| Event | Description | Payload |
|---|---|---|
| update:modelValue | Keyword change (debounced; v-model write-back path) | value: string |
| search | Submit search (native input confirm-type=search) | value: string |
| cancel | Cancel button click | — |
| clear | Clear button click (writes back empty string) | — |
| focus | Focus | — |
| blur | Blur (flushes pending debounced value) | — |
Accessibility
The root aria-label falls back through ariaLabel > placeholder > value; the clear button carries its own aria-label="清除".

