Skip to content

WtSearchBar

Props

NameTypeDefaultDescription
valueString''The value of the search bar
placeholderString'Search'The placeholder of the search bar
hintString''The hint of the search bar
vObject''Validation object
customValidatorsArray[]Custom validators for validation object
searchModeString''The search mode of the search bar
searchModeOptionsArray[]The search mode options of the search bar

Events

NameParamsDescription
inputvalue: StringEmitted when the value of the search bar changes (not debounced!)
searchvalue: StringSends changed value, immediately, or, if "debounced" is on, debounced. Recommended for api search requests

Slots

NameScopeDescription
search-icon{ invalid: Boolean }Change default search icon
additional-actions{ invalid: Boolean }Adding additional functionality to search bar. For example wt-context-menu
Code
vue
<script setup>
import { ref } from 'vue';

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

<template>
  <wt-search-bar
    :value="value"
    placeholder="Search"
    @input="value = $event"
  />
</template>

<style scoped lang="scss"></style>

Example HintedSearchBar

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

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

<template>
  <wt-search-bar
    :value="value"
    placeholder="Search"
    hint="I am hinted!"
    @input="value = $event"
  />
</template>

<style scoped lang="scss"></style>

Example InvalidSearchBar

Code
vue
<script setup>
import { useVuelidate } from '@vuelidate/core';
import { computed,ref } from 'vue';

const value = ref('');
const v$ = useVuelidate(
  computed(() => ({
    value: {
      required: () => false,
    },
  })),
  { value },
);

v$.value.$touch();
</script>

<template>
  <wt-search-bar
    :value="value"
    placeholder="Invalid Search"
    :v="v$"
    @input="value = $event"
  />
</template>

<style scoped lang="scss"></style>

Example SearchBarWithSearchModes

Value:

Search mode: { "value": "mode 1", "text": "Mode 1" }

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

const value = ref('');

const searchModeOptions = [
  {
    value: 'mode 1',
    text: 'Mode 1',
  },
  {
    value: 'mode 2',
    text: 'Mode 2',
  },
];

const searchMode = ref(searchModeOptions[0]);
</script>

<template>
  <wt-search-bar
    :value="value"
    placeholder="Search"
    hint="I have search modes!"
    :search-mode="searchMode"
    :search-mode-options="searchModeOptions"
    @input="value = $event"
    @change:search-mode="searchMode = $event"
  />
  <p>Value: {{ value }}</p>
  <p>Search mode: {{ searchMode }}</p>
</template>

<style scoped lang="scss"></style>