Basic search input
Sizes
Small
Medium
Large
Search input - custom height 60px
Search input in popups or dialog menus
When wui-search-input
is placed with 100% width in a popup or dialog menu, the top, left and right borders are removed.
Search icon at start
The wui-search-input
can also have the search icon at the beginning of the input field:
Combine search input with custom icons
Search input with custom filter icon at the end
WUI decisions 
- Default setup. If there is only one search on the respective page, it should be initially focused.
- Search as you type. After entering 2 characters the search starts. In languages where words can also be made up of a single character (e.g. Chinese, Korean, ...) the search is started as soon as the first character is entered.
- Cross-lingual. If you search for "germany", a possible search result would be "Deutschland" as well.
- AND-linked-infix. The more keywords you enter, the more accurate your search will be. As a result, the user gets fewer - but more precise - search hits.
- No WYSIWYG. For technical reasons, the fields are searched as they occur in the database. If "Paderborn" and "deutsch" are available in the database, the search for
born (d
would not find a hit, even if "Paderborn (de)" is displayed in the UI. - Invisible fields. In addition to the visible fields, other relevant fields can also be searched in the background. Even if only the name "Juliane Becker" is displayed in the UI, the user could get a hit by searching for "jbecker@de.movisia.com".
- Clear search. Clicking on "" or will clear the search and trigger a new one.
- Search and filtering. If the user has already limited the search results via filtering, the search will only refer to this result set. The search must not reset the filters.
- Scoped search. The search only affects the area in which it is located.
- Hits-indicator. All items on the page that display the number of hits, change them according to the search results. (If it is technically possible and if the loading times do not increase significantly by that)
- Min-width. As a rule of thumb, an input with a length of 27 characters covers 90% of the search queries. That's why we set a fixed width of 300px for search inputs.
- Placeholder. Since each search can potentially return several hits, the placeholder is always in plural. In addition, the placeholder always contains an hint of what is searched.
- Empty-state. If there are no search hits, we use
.wui-empty-state
. You'll find the right image and further information at images
Description
<wui-search-input>
is a more specific version of <wui-form-input>
, which additionally renders <wui-input-group>
with a search icon and a clear button.
Please note: The default import of the search-input component points to a deprecated version. Please use the named export "
WuiSearchInput
".
Control sizing
Set heights using the size
prop to sm
or lg
for small or large respectively.
To control width, place the input inside standard WUI grid column.
<template>
<wui-form>
<wui-form-group>
<p>Small</p>
<wui-search-input v-model="query" size="sm" />
</wui-form-group>
<wui-form-group>
<p>Medium</p>
<wui-search-input v-model="query" />
</wui-form-group>
<wui-form-group>
<p>Large</p>
<wui-search-input v-model="query" size="lg" />
</wui-form-group>
</wui-form>
</template>
<script>
export default {
data() {
return {
query: "false",
};
},
};
</script>
<!-- wui-search-input-size.vue -->
Custom height
You can also specify a custom size by setting the height
property via CSS class or style
attribute:
<template>
<wui-form>
<wui-form-group>
<p>Search input - custom height 60px</p>
<wui-search-input v-model="query" style="height: 60px" />
</wui-form-group>
</wui-form>
</template>
<script>
export default {
data() {
return {
query: "false",
};
},
};
</script>
<!-- wui-search-input-custom-size.vue -->
Remove surrounding borders
When wui-search-input
is placed with 100% width in a popup or dialog menu, the top, left and right borders can be removed with the border-bottom-only
prop.
<template>
<div>
<wui-button
id="example-btn-search"
variant="default"
outline
title="Search"
v-w-popup.example-popup-search
>
Open search dialog
</wui-button>
<wui-popup
ref="example-popup-search"
id="example-popup-search"
:offset="{ crossAxis: -50 }"
:shift="true"
target="example-btn-search"
>
<wui-search-input
ref="example-popup-search-input"
v-model="query"
class="wui-popup-search"
border-bottom-only
:trim="true"
placeholder="Search keywords"
style="height: 40px"
></wui-search-input>
<div id="results" class="m-t-30" style="min-width: 300px"> </div>
</wui-popup>
</div>
</template>
<script>
export default {
data() {
return {
query: "false",
};
},
};
</script>
<!-- wui-search-input-border-bottom-only.vue -->
Remove clear button
If you don't want the clear functionality, the corresponding button can be hidden with the no-clear-button
prop.
<template>
<wui-form>
<wui-form-group>
<wui-search-input v-model="query" :no-clear-button="true" />
</wui-form-group>
</wui-form>
</template>
<script>
export default {
data() {
return {
query: "false",
};
},
};
</script>
<!-- wui-search-input-no-clear-button.vue -->
Search icon at start
You can also display the search icon at the beginning of the input field by setting the search-icon-start
property to true
:
<template>
<wui-form>
<wui-form-group>
<wui-search-input v-model="query" :search-icon-start="true" />
</wui-form-group>
</wui-form>
</template>
<script>
export default {
data() {
return {
query: "false",
};
},
};
</script>
<!-- wui-search-input-search-icon-start.vue -->
Input busy state
<wui-search-input>
provides a busy
prop that will flag the search input as busy, which you can set to true
or false
at any time. When in the busy state, the search root element will have the attribute aria-busy="true"
. The search input will also render a loading spinner instead of the search or clear icon.
Custom rendering via slots
Custom rendering of icons, buttons or text content is possible using append*
and prepend*
slots.
The search input field is wrapped in a <wui-input-group>
. <wui-search-input>
uses <wui-input-group-prepend>
and <wui-input-group-append>
to display the search icons and clear button at the beginning or end . You can add more input group elements by using the prepend-start
, prepend-end
, append-start
or append-end
slots.
prepend-start
- content to place at the beginning of the prepend section. Content will be placed before the search icon ifsearchIconStart
is setprepend-end
- content to place at the end of the prepend section. Content will be placed after search icon ifsearchIconStart
is setappend-start
- content to place at the beginning of the append section. Content will be placed before the clear button and search iconappend-end
- content to place at the end of the append section. Content will be placed after the clear button and search icon
Please note: if you use the
prepend
orappend
slots, the search icon and clear button will be overridden.
<template>
<wui-form>
<wui-form-group>
<p>Search input with custom filter icon at the end</p>
<wui-search-input v-model="query">
<template #append-end>
<wui-button variant="default" outline>
<wui-fa-icon icon="filter" />
</wui-button>
</template>
</wui-search-input>
</wui-form-group>
<wui-form-group>
<p>
Search input with custom paw icon (if you need one) *before* the search
icon
</p>
<wui-search-input v-model="query">
<template #append-start>
<wui-input-group-text class="wui-bg-color--white border-0 p-x-10">
<wui-fa-icon icon="paw" />
</wui-input-group-text>
</template>
</wui-search-input>
</wui-form-group>
<wui-form-group>
<p>Replaces the search icon and clear button</p>
<wui-search-input v-model="query">
<template #append>
<wui-input-group-append>
<wui-button
v-if="query"
variant="default"
outline
title="clear"
@click="query = ''"
>
<wui-fa-icon :icon="['far', 'eraser']" />
</wui-button>
<wui-input-group-text
v-else
class="wui-bg-color--white border-0 p-x-10"
><wui-fa-icon :icon="['far', 'file-magnifying-glass']"
/></wui-input-group-text>
</wui-input-group-append>
</template>
</wui-search-input>
</wui-form-group>
</wui-form>
</template>
<script>
export default {
data() {
return {
query: "false",
};
},
};
</script>
<!-- wui-search-input-slots.vue -->
Contextual states
See the wui-form-input docs
Formatter support
See the wui-form-input docs
v-model
modifiers
See the wui-form-input docs
Debounce support
See the wui-form-input docs
Autofocus
See the wui-form-input docs
Native and custom events
See the wui-form-input docs
Exposed input properties and methods
See the wui-form-input docs
Component reference
<wui-search-input>
<wui-search-input>
Properties<wui-search-input>
v-model
<wui-search-input>
Slots<wui-search-input>
Events
Properties
Note:
<wui-search-input>
uses<wui-form-input>
under the hood and therefore inherits all of its props exceptlist
,max
,min
,noWheel
,plaintext
,step
andtype
(see the wui-form-input docs).
Property | Type | Default | Description |
---|---|---|---|
append-css | String , Array or Object | CSS class (or classes) to apply to the input group append element | |
busy | Boolean | false | When set, forces the search input into the busy state |
border-bottom-only | Boolean | false | Removes the borders expect from the bottom. Use this for full width search inputs at the top in dropdown like components |
input-css | String , Array or Object | CSS class (or classes) to apply to the form input element | |
no-clear-button | Boolean | false | Hides the clear button |
prepend-css | String , Array or Object | CSS class (or classes) to apply to the input group prepend element | |
search-icon-start | Boolean | false | Whether the search icon should be placed at the beginning of the input field or not |
type | String | text | The type of input to render (supported types: text (default), search , email ) |
value v-model | String | '' | The current value of the input |
wrapperAttrs | String , Array or Object | {} | Any HTML attributes you want to pass to the search input root element |
v-model
Property | Event |
---|---|
value | update |
Slots
Name | Description |
---|---|
append | Content to place in the append section. Will replace the clear button and search icon |
append-start | Content to place at the beginning of the append section. Content will be placed before the clear button and search icon |
append-end | Content to place at the end of the append section. Content will be placed after the clear button and search icon |
default-icon | Content you want to replace the search icon with. Will be placed inside of wui-input-group-append (if search-icon-start is true ) or wui-input-group-prepend (default) |
prepend | Content to place in the prepend section. Will replace the search icon if searchIconStart is set |
prepend-start | Content to place at the beginning of the prepend section. Content will be placed before the search icon if searchIconStart is set |
prepend-end | Content to place at the end of the prepend section. Content will be placed after search icon if searchIconStart is set |
Events
Event | Arguments | Description |
---|---|---|
blur | event - Native blur event (before any formatting) | Emitted after the input looses focus |
change | value - Current value of input | Change event triggered by user interaction. Emitted after any formatting (not including 'trim' or 'number' props) and after the v-model is updated |
clear | MouseEvent - Native click event object | Emitted when the user clicks on the clear button |
input | value - Current value of input | Input event triggered by user interaction. Emitted after any formatting (not including 'trim' or 'number' props) and after the v-model is updated |
update | value - Value of input, after any formatting. Not emitted if the value does not change | Emitted to update the v-model |
<wui-search-input-header>
@deprecated
<wui-search-input-header>
Properties<wui-search-input-header>
v-model
<wui-search-input-header>
Events
Properties
Property | Type | Default | Description |
---|---|---|---|
debounce-duration | Number | 0 | When set to a number of milliseconds greater than zero, will debounce the user input |
has-error | Boolean | false | Whether ot not the search input should render in error state |
input-css | String | '' | CSS class (or classes) to apply to the form input element |
value v-model | String | undefined | The current value of the input |
v-model
Property | Event |
---|---|
value | input |
Events
Event | Arguments | Description |
---|---|---|
onClear | Emitted when the user clicks on the clear button |
Importing individual components
You can import individual components into your project via the following named exports:
Component | Named Export |
---|---|
<wui-search-input> | WuiSearchInput |
Example
import { WuiSearchInput } from "@wui/wui-vue/lib/search-input";
Vue.component("wui-search-input", WuiSearchInput);
Importing as a Vue.js plugin
This plugin includes all of the above listed individual components. Plugins also include any component aliases.
Named Export | Import Path |
---|---|
SearchInputPlugin | @wui/wui-vue/lib/search-input |
Example
import { SearchInputPlugin } from "@wui/wui-vue/lib/search-input";
Vue.use(SearchInputPlugin);