ais-refinement-list
<ais-refinement-list attribute="string" // Optional parameters operator="string" :limit="number" :show-more="boolean" :show-more-limit="number" :searchable="boolean" :searchable-placeholder="string" :sort-by="string[]|function" :transform-items="function" :class-names="object" />
About this widget
The ais-refinement-list
widget is one of the most common widget you can find in a search UI. With this widget, the user can filter the dataset based on facets.
The widget only displays the most relevant facets for the current search context. The sort option only affects the facets that are returned by the engine, not which facets are returned.
This widget also implements search for facet values, which is a mini search inside the values of the facets. This makes it easy to deal with uncommon facet values.
Requirements
The attribute passed to the attribute
prop must be added in attributes for faceting, either on the dashboard or using attributesForFaceting with the API.
If you are using the searchable
prop, you also need to make the attribute searchable using the dashboard or using the searchable
modifier of attributesForFaceting with the API.
Examples
1
<ais-refinement-list attribute="brand" />
Props
attribute
|
type: string
Required
The name of the attribute in the records. |
||
Copy
|
|||
operator
|
type: string ("or"|"and")
default: "or"
Optional
How to apply refinements.
|
||
Copy
|
|||
limit
|
type: number
default: 10
Optional
The minimum number of facet values to retrieve. |
||
Copy
|
|||
show-more
|
type: boolean
default: false
Optional
Whether to display a button that expands the number of items. |
||
Copy
|
|||
show-more-limit
|
type: number
default: 20
Optional
The maximum number of displayed items (only used when show-more is set to |
||
Copy
|
|||
searchable
|
type: boolean
default: false
Optional
Adds a search input to let the user search for more facet values. To make this feature work, you need to make the attribute searchable using the dashboard or using the |
||
Copy
|
|||
searchable-placeholder
|
type: string
default: "Search here…"
Optional
The value of the search input placeholder. |
||
Copy
|
|||
sort-by
|
type: string[]|function
default: ["isRefined", "count:desc", "name:asc"]
How to sort refinements. Must be one or more of the following strings:
It’s also possible to give a function, which receives items two by two, like JavaScript’s |
||
Copy
|
|||
transform-items
|
type: function
default: x => x
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
|
|||
item
|
The slot to override the DOM output of an item. Scope
Where an item is an
|
||
Copy
|
|||
showMoreLabel
|
The slot to override the DOM output of the “Show more” button. Scope
|
||
Copy
|
|||
noResults
|
The slot to override the DOM output of the no results placeholder. Scope
|
||
Copy
|
HTML output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<div class="ais-RefinementList">
<div class="ais-RefinementList-searchBox">
<!-- SearchBox widget here -->
</div>
<ul class="ais-RefinementList-list">
<li class="ais-RefinementList-item ais-RefinementList-item--selected">
<label class="ais-RefinementList-label">
<input class="ais-RefinementList-checkbox" type="checkbox" value="Insignia™" checked />
<span class="ais-RefinementList-labelText">Insignia™</span>
<span class="ais-RefinementList-count">746</span>
</label>
</li>
<li class="ais-RefinementList-item">
<label class="ais-RefinementList-label">
<input class="ais-RefinementList-checkbox" type="checkbox" value="Samsung">
<span class="ais-RefinementList-labelText">Samsung</span>
<span class="ais-RefinementList-count">633</span>
</label>
</li>
</ul>
<button class="ais-RefinementList-showMore">Show more</button>
</div>