Signature
Import
- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
About this widget
Theais-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 users 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
Vue
Props
The list of indices to search in, with each item:
label: string
. The label of the index to display.value: string
. The name of the index to target.
Vue
To prevent creating infinite loops,
avoid passing arrays, objects, or functions directly in the template.
These values aren’t referentially equal on each render,
which causes the widget to re-register every time.
Instead, define them in your component’s
data
option and reference them in the template.Vue
The CSS classes you can override:
ais-SortBy
. The root of the widgetais-SortBy-select
. Theselect
element.ais-SortBy-option
. Theoption
element of theselect
.
Vue
Customize the UI
default
The slot to override the complete DOM output of the widget.When you implement this slot,
none of the other slots will change the output,
as the default slot surrounds them.Scope
items: object[]
. The list of items the widget can display.currentRefinement: string
. The currently applied refinement.canRefine: boolean
. Whether a refinement can be applied.refine: (value: string) => void
. The function to call with the next value of the index name.
object
containing:label: string
. The label of the index to display.value: string
. The name of the index to target.
Vue
HTML output
HTML