Pre-configured search input with a magnifying glass icon and clear button.
< script setup >
import { ref } from 'vue'
const val = ref ( '' )
</ script >
< template >
< PSearchInput v-model = " val " placeholder = "Enter some text..." />
</ template >
< script setup >
import { ref } from 'vue'
const val = ref ( '' )
</ script >
< template >
< PSearchInput v-model = " val " disabled placeholder = "Enter some text..." />
</ template >
< script setup >
import { ref } from 'vue'
const val = ref ( '' )
const loading = ref ( false )
function handleSearch () {
loading.value = true
setTimeout (() => {
loading.value = false
}, 2000 )
}
</ script >
< template >
< PSearchInput v-model = " val " : loading = " loading " placeholder = "Enter some text..." @ search = " handleSearch " />
</ template >
< script setup >
import { ref } from 'vue'
import SparklesIcon from '@gdsicon/vue/sparkles'
const val = ref ( '' )
</ script >
< template >
< PSearchInput v-model = " val " placeholder = "Enter some text..." >
< template # prefix >
< SparklesIcon />
</ template >
</ PSearchInput >
</ template >
Name Type Default Description loading booleanfalseReplaces the prefix with a loading icon.
SearchInput extends the Input component : every other prop and event — v-model, size, disabled, clearable, @focus, @click, the native input event — is forwarded to PInput unchanged.
Name Type Description search (value: string) => voidEmitted when Enter is pressed with a non-empty value while not loading. update:model-value (value: string) => voidEmitted when the query changes, forwarded from PInput.
Name Description prefix Custom prefix content. The loading icon replaces this slot while loading is true. suffix Custom suffix content, forwarded to PInput.
Name Type Description blur () => voidBlur the underlying input. clear (event?: Event) => voidClear the underlying input and emit change. focus () => voidFocus the underlying input. select () => voidSelect the text of the underlying input.