Signature
Import
- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
About this widget
Theais-menu-select
widget allows a user to select a single value to refine inside a select
element.
Requirements
Theattribute
provided to the widget must be in attributes for faceting,
either on the dashboard or using the attributesForFaceting
parameter with the API.
Examples
Vue
Props
The name of the attribute in the record.
Vue
The maximum number of values to display.
Vue
How to sort refinements. Must be one or more of the following strings:
"count:asc"
"count:desc"
"name:asc"
"name:desc"
"isRefined"
Array.sort
.If facetOrdering
is set for this facet in renderingContent
,
and no value for sortBy
is passed to this widget,
facetOrdering
is used, and the default order as a fallback.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
A function that receives the list of items before they are displayed.
It should return a new array with the same structure.
Use this to transform, filter, or reorder the items.The function also has access to the full
results
data,
including all standard response parameters
and parameters from the helper,
such as disjunctiveFacetsRefinements
.Vue
The CSS classes you can override:
.ais-MenuSelect
. The root element of the widget.ais-MenuSelect--noRefinement
. The root element of the widget with no refinement.ais-MenuSelect-select
. Theselect
element.ais-MenuSelect-option
. Theoption
elements 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 values applicable to this menu. -
canRefine: boolean
. Can the refinement be applied? -
refine: (value: string) => void
. A function to select a refinement. -
createURL: (item: string) => string
. A function to return a link for this refinement. -
sendEvent: (eventType: 'click', facetValue: string) => void
. The function to sendclick
events.- The
view
event is automatically sent when the facets are rendered. - The
click
event is automatically sent whenrefine
is called.
insights
middleware. - The
object
containing:value: string
. The value of the menu item.label: string
. Human-readable value of the menu item.count: number
. Number of results matched after a refinement is applied.isRefined: boolean
. Indicates if the refinement is applied.
Vue
item
The slot to override the content of an
option
element.
Make sure to use template
as the root,
since any other elements inside an option
are not allowed.Scopeitem: object
. The values applicable to theoption
.
object
containing:value: string
. The value of the menu item.label: string
. Human-readable value of the menu item.count: number
. Number of results matched after a refinement is applied.isRefined: boolean
. Indicates if the refinement is applied.
Vue
defaultOption
The slot to override the content of the
option
element which selects “all items”.
Make sure to use template
as the root, since any other elements inside an option
are not allowed.ScopeNo scope is provided to this slot.Vue
HTML output
HTML
If SEO is important for your search page, ensure that your custom HTML is optimized for search engines:
- Use
<a>
tags withhref
attributes to allow search engine bots to follow links. - Use semantic HTML and include structured data when relevant.