ais-search-box
<ais-search-box // Optional parameters placeholder="string" submit-title="string" reset-title="string" :autofocus="boolean" :show-loading-indicator="boolean" :class-names="object" />
About this widget
The ais-search-box
widget is used to let the user set a text-based query.
This usually is the main entry point to start the search in an InstantSearch context. It is usually placed at the top of a search experience, so that the user can start searching right away.
Examples
1
<ais-search-box />
Props
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
|
|||
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 to override.
|
||
Copy
|
Customize the UI
default
|
The slot to override the complete DOM output of the widget. 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>