ais-sort-by
<ais-sort-by :items="object[]" // Optional parameters :transform-items="function" :class-names="object" />
About this widget
The ais-sort-by
widget displays a list of indices, allowing a user to change the way hits are sorting (with replica indices). Another common use case for this widget is to let the user switch between different indices.
For this widget to work, you must define all indices that you pass down as options as replicas of the main index.
Examples
1
2
3
4
5
6
7
<ais-sort-by
:items="[
{ value: 'instant_search', label: 'Featured' },
{ value: 'instant_search_price_asc', label: 'Price asc.' },
{ value: 'instant_search_price_desc', label: 'Price desc.' },
]"
/>
Props
items
|
type: object[]
Required
The list of indices to search in, with each item:
|
||
Copy
|
|||
transform-items
|
type: function
default: items => items
Optional
Receives the items, and is called before displaying them. Should return a new array with the same shape as the original array. Useful for mapping over the items to transform, and remove or reorder them. |
||
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
Where each item is an
|
||
Copy
|
HTML output
1
2
3
4
5
6
7
<div class="ais-SortBy">
<select class="ais-SortBy-select">
<option class="ais-SortBy-option" value="instant_search">Featured</option>
<option class="ais-SortBy-option" value="instant_search_price_asc">Price asc.</option>
<option class="ais-SortBy-option" value="instant_search_price_desc">Price desc.</option>
</select>
</div>