ais-menu
<ais-menu attribute="string" // Optional parameters :limit="number" :show-more="boolean" :show-more-limit="number" :sort-by="string[]|function" :transform-items="function" :class-names="object" />
About this widget
The ais-menu
widget displays a menu that lets the user choose a single value for a specific attribute.
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.
Examples
1
<ais-menu attribute="categories" />
Props
attribute
|
type: string
Required
The name of the attribute in the record. |
||
Copy
|
|||
limit
|
type: number
default: 10
Optional
How many facet values to retrieve. When you enable the show-more feature, this is the number of facet values to display before clicking the “Show more” button. |
||
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
Amount of items to show if showing more. Requires show-more to be |
||
Copy
|
|||
sort-by
|
type: string[]|function
default: Uses facetOrdering if set, ["name:asc", "count:desc"]
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 If When using an array, take steps to avoid creating infinite loops. When you use an array as a prop, it causes the widget to re-register on every render, and this can sometimes cause these infinite loops. |
||
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 transforming, removing, or reordering items. In addition, the full |
||
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. Note that when you implement this slot, none of the other slots will change the output, as the default slot surrounds them. Scope
Where each item is an
|
||
Copy
|
|||
showMoreLabel
|
The slot to override the DOM output for the label of the “Show more” button. Scope
|
||
Copy
|
HTML output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="ais-Menu">
<ul>
<li>
<a class="ais-Menu-link">
<span class="ais-Menu-label">Apple</span>
<span class="ais-Menu-count">50</span>
</a>
</li>
<!-- more items -->
</ul>
<button class="ais-Menu-showMore">
Show more
</button>
</div>
If SEO is critical to your search page, your custom HTML markup needs to be parsable:
- use plain
<a>
tags withhref
attributes for search engines bots to follow them, - use semantic markup with structured data when relevant, and test it.
Refer to our SEO checklist for building SEO-ready search experiences.