Skip to content

Search Field

Combined search input and submit button with optional autocomplete suggestions.

Demo

Basic

Large

With suggestions

Disabled

Installation

vue
<script setup>
import { GTSearchField } from '@grundtone/vue';
</script>

In Nuxt, GTSearchField is auto-imported.

When to use

Use when users need to search for content by keyword. Minimum 27 characters wide.

Do not use on single-page sites or where search is unnecessary.

Usage

Basic

vue
<GTSearchField v-model="query" @submit="search" />

Large

vue
<GTSearchField v-model="query" size="lg" placeholder="Søg i dokumentation..." />

With suggestions

vue
<GTSearchField
  v-model="query"
  :suggestions="filteredResults"
  @submit="search"
/>

Props

PropTypeDefaultDescription
modelValuestring''Search query (v-model)
placeholderstring'Søg...'Placeholder text
labelstring'Søg'Accessible label (sr-only)
buttonLabelstring'Søg'Submit button label
size'md' | 'lg''md'Size preset
disabledbooleanfalseDisabled state
idstringautoHTML id
suggestionsSearchSuggestion[]Autocomplete suggestions
loadingbooleanfalseLoading state
minCharsnumber2Min chars before suggestions
noResultsTextstring'Ingen resultater'Empty state text

SearchSuggestion

PropertyTypeDescription
valuestringSubmitted value
labelstringDisplay text

Events

EventPayloadDescription
update:modelValuestringInput change
submitstringSearch submitted (enter or button click)

Accessibility

  • <form role="search"> wrapper
  • Visually hidden label
  • type="search" + inputmode="search"
  • Arrow keys navigate suggestions
  • Enter selects highlighted suggestion or submits
  • Escape closes suggestions

See Search Field (Design System) for full CSS reference.