Formulários

VSearchField

Componentev-model8 exemplos20 propsA2UI · SearchField

Campo de busca com ícone, clear, atalho ⌘K, sugestões e loading.

Importação
<script setup lang="ts">
import { VSearchField } from 'vueui-nova-kit'
</script>

Uso

Exemplo
<script setup lang="ts">

</script>

<template>
  
</template>

Playground

Os controles abaixo são gerados a partir das props declaradas em VSearchField.types.ts; o código acompanha cada mudança.

Exemplos

Variantes, tamanhos e estados, extraídos das stories da biblioteca.

Default

Variação Padrão. Estado padrão do componente; use a aba Controls para experimentar as props ao vivo. Props: label="Search", placeholder="Search for anything...".

Ver código
vue
<script setup lang="ts">
import { VSearchField } from 'vueui-nova-kit'
</script>

<template>
  <VSearchField
    v-model="value"
    placeholder="Search for anything..."
    label="Search" />
</template>

With Shortcut

Variação Com Shortcut. Props: variant="shortcut", shortcut=true, placeholder="Search or jump to...".

Ver código
vue
<script setup lang="ts">
import { VSearchField } from 'vueui-nova-kit'
</script>

<template>
  <VSearchField
    v-model="value"
    placeholder="Search or jump to..."
    variant="shortcut"
    shortcut />
</template>

Command

Variação Command. Props: variant="command", shortcut=true, placeholder="Type a command or search...".

Ver código
vue
<script setup lang="ts">
import { VSearchField } from 'vueui-nova-kit'
</script>

<template>
  <VSearchField
    v-model="value"
    placeholder="Type a command or search..."
    variant="command"
    shortcut />
</template>

With Suggestions

Variação Com Suggestions. Interativo: o estado é mantido na própria story (v-model).

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VSearchField } from 'vueui-nova-kit'

const query = ref('Vue')
const suggestions = [
  {
    value: 'vue',
    label: 'vue',
    category: 'Search suggestion'
  },
  {
    value: 'Vue components',
    label: 'Vue components',
    category: 'Documentation'
  },
  {
    value: 'vue-router',
    label: 'vue-router',
    category: 'Package'
  },
  {
    value: 'Vue CLI',
    label: 'Vue CLI',
    category: 'Command'
  }
]
</script>

<template>
  <VSearchField
    v-model="query"
    label="Search"
    placeholder="Search products, docs, or anything..."
    :suggestions="suggestions" />
</template>

Loading

Variação Carregando. Props: label="Search", modelValue="Vue", loading=true, placeholder="Searching...".

Ver código
vue
<script setup lang="ts">
import { ref } from 'vue'
import { VSearchField } from 'vueui-nova-kit'

const value = ref('Vue')
</script>

<template>
  <VSearchField
    v-model="value"
    placeholder="Searching..."
    label="Search"
    loading />
</template>

Disabled

Variação Desabilitado. Props: label="Search", placeholder="Search for anything...", disabled=true.

Ver código
vue
<script setup lang="ts">
import { VSearchField } from 'vueui-nova-kit'
</script>

<template>
  <VSearchField
    v-model="value"
    placeholder="Search for anything..."
    label="Search"
    disabled />
</template>

Sizes

Variação Tamanhos.

Ver código
vue
<script setup lang="ts">
import { VSearchField } from 'vueui-nova-kit'
</script>

<template>
  <div style="display:flex;flex-direction:column;gap:16px;max-width:480px">
    <VSearchField size="sm" label="Small" placeholder="Search..." />
    <VSearchField size="md" label="Medium" placeholder="Search..." />
    <VSearchField size="lg" label="Large" placeholder="Search..." />
  </div>
</template>

Custom Shortcut Keys

Variação Personalizado Shortcut Keys. Props: variant="shortcut", shortcut=true, shortcutKeys="Ctrl K".

Ver código
vue
<script setup lang="ts">
import { VSearchField } from 'vueui-nova-kit'
</script>

<template>
  <VSearchField
    v-model="value"
    placeholder="Search products, docs, or anything..."
    variant="shortcut"
    shortcut
    shortcut-keys="Ctrl K" />
</template>

Acessibilidade

Checklist literal ("Accessibility — Inclusive by design"):

  • Minimum hit target — 44 × 44px.
  • Labelled with accessible name — aria-label or <label>.
  • Keyboard navigation — Tab, Esc to close.
  • Clear action announced — aria-label="Clear search".
  • Suggestions use listbox — role="listbox" + aria-activedescendant.
  • Focus visible — Clear focus indicator.
  • High contrast support — Validated (WCAG AA).
  • Disabled state — aria-disabled="true".

Estados

Default · Hover · Focus · Typing · With value · Suggestions open · Loading · Disabled.

Motion

Hover 120ms · focus ring 120ms · painel fade+slide 160ms · clear fade/scale 100ms.

Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.

Props

PropTipoDefaultDescrição
modelValuestring""—
labelstring——
placeholderstring——
disabledbooleanfalse—
loadingbooleanfalse—
sizeVSearchFieldSize"md"—
variantVSearchFieldVariant——
shortcutbooleanfalse—
shortcutKeysstring——
clearablebooleantrue—
clearLabelstring——
suggestionsVSearchFieldSuggestion[][]—
namestring——
idstring——
autocompletestring——
ariaLabelstring——
inputTestIdstring—data-test-id do <input> (padrão 'v-searchfield-input').
clearTestIdstring—data-test-id do botão limpar (padrão 'v-searchfield-clear').
shortcutTestIdstring—data-test-id do atalho (padrão 'v-searchfield-shortcut').
extraInputAttrsRecord<string, unknown>—Atributos extras aplicados ao <input> por último (aria-*, class, data-test-id, value...). Retrocompatível: ausente = sem efeito.

Events

EventoPayloadDescrição
@update:modelValuevalue: string—
@clear——
@searchvalue: string—
@selectsuggestion: import('./VSearchField.types').VSearchFieldSuggestion—
@focuspayload: FocusEvent—
@blurpayload: FocusEvent—
@shortcut——

Slots

SlotProps do slot
#icon—

Fonte: src/components/form/VSearchField/VSearchField.vue · tipos: src/components/form/VSearchField/VSearchField.types.ts