PXD
v0.2.1-dev

Search Input

Pre-configured search input with a magnifying glass icon and clear button.

Default

<script setup>
import { ref } from 'vue'

const val = ref('')
</script>

<template>
  <PSearchInput v-model="val" placeholder="Enter some text..." />
</template>

Disabled

<script setup>
import { ref } from 'vue'

const val = ref('')
</script>

<template>
  <PSearchInput v-model="val" disabled placeholder="Enter some text..." />
</template>

Loading

<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>

Custom Prefix

<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>

Props

NameTypeDefaultDescription
loadingbooleanfalseReplaces 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.

Events

NameTypeDescription
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.

Slots

NameDescription
prefixCustom prefix content. The loading icon replaces this slot while loading is true.
suffixCustom suffix content, forwarded to PInput.

Methods

NameTypeDescription
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.

Source

Source