ais-search-box
<ais-search-box // Optional parameters placeholder="string" submit-title="string" reset-title="string" :autofocus="boolean" :ignore-composition-events="boolean" :show-loading-indicator="boolean" :class-names="object" />
1
2
3
4
5
6
7
8
9
import { AisSearchBox } from 'vue-instantsearch';
// Use 'vue-instantsearch/vue3/es' for Vue 3
export default {
components: {
AisSearchBox
},
// ...
};
1. Follow additional steps in Optimize build size to ensure your code is correctly bundled.
2. This imports all the widgets, even the ones you don’t use. Read the Getting started guide for more information.
About this widget
The ais-search-box
widget is used to let users set a text-based query.
This usually is the main entry point to start the search in an InstantSearch context. It’s usually placed at the top of a search experience, so that users can start searching right away.
Examples
1
<ais-search-box />
Props
Parameter | Description | ||
---|---|---|---|
placeholder
|
type: string
default: Search here…
Optional
The input placeholder. |
||
Copy
|
|||
submit-title
|
type: string
default: search
Optional
The submit button text. |
||
Copy
|
|||
reset-title
|
type: string
default: clear
Optional
The clear button text. |
||
Copy
|
|||
autofocus
|
type: boolean
default: false
Optional
Whether to automatically focus on the input when rendered. |
||
Copy
|
|||
ignore-composition-events
|
since: v4.13.6
type: boolean
default: false
Optional
Whether to update the search state in the middle of a composition session. This is useful when users need to search using non-latin characters. |
||
Copy
|
|||
show-loading-indicator
|
type: boolean
default: false
Optional
Whether to show the loading indicator (replaces the submit button if the search is stalled). |
||
Copy
|
|||
class-names
|
type: object
default: {}
Optional
The CSS classes you can override:
|
||
Copy
|
Customize the UI
Parameter | Description | ||
---|---|---|---|
default
|
The slot to override the complete DOM output of the widget. Note that when you implement this slot, none of the other slots will change the output, as the default slot surrounds them. Scope
|
||
Copy
|
|||
submit-icon
|
The slot to override the DOM output of the submit icon. ScopeNo props are provided. |
||
Copy
|
|||
reset-icon
|
The slot to override the DOM output of the reset icon. ScopeNo props are provided. |
||
Copy
|
|||
loading-indicator
|
The slot to override the DOM output of the loading indicator. ScopeNo props are provided. |
||
Copy
|
HTML output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<div class="ais-SearchBox">
<form class="ais-SearchBox-form" novalidate>
<input class="ais-SearchBox-input" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="Search for products" spellcheck="false" maxlength="512" type="search" value="" />
<button class="ais-SearchBox-submit" type="submit" title="Submit the search query.">
<svg class="ais-SearchBox-submitIcon" xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 40 40">
...
</svg>
</button>
<button class="ais-SearchBox-reset" type="reset" title="Clear the search query." hidden>
<svg class="ais-SearchBox-resetIcon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" width="10" height="10">
...
</svg>
</button>
<span class="ais-SearchBox-loadingIndicator" hidden>
<svg width="16" height="16" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg" stroke="#444" class="ais-SearchBox-loadingIcon">
...
</svg>
</span>
</form>
</div>