Skip to main content
Signature

Import

To ensure optimal bundle sizes, see Optimize build size.
Vue

See this widget in action

Preview this widget and its behavior.

About this widget

The ais-menu widget displays a menu that lets users choose a single value for a specific attribute.
The ais-menu widget uses a hierarchical refinement internally, so it can’t refine values that include the default separator (>). To support these values, use the ais-hierarchical-menu widget instead.

Requirements

The attribute 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

attribute
string
required
The name of the attribute in the record.To avoid unexpected behavior, you can’t use the same attribute prop in a different type of widget.
Vue
limit
number
default:10
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.
Vue
show-more
boolean
default:false
Whether to display a button that expands the number of items.
Vue
show-more-limit
number
default:20
Amount of items to show if showing more. Requires show-more to be true.
Vue
sort-by
string[] | function
How to sort refinements. Must be one or more of the following strings:
  • "count" (same as "count:desc")
  • "count:asc"
  • "count:desc"
  • "name" (same as "name:asc")
  • "name:asc"
  • "name:desc"
  • "isRefined" (same as "isRefined:asc")
  • "isRefined:asc"
  • "isRefined:desc"
It’s also possible to give a function, which receives items two by two, like JavaScript’s 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
transform-items
function
default:"items => items"
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
class-names
object
default:"{}"
The CSS classes you can override:
  • .ais-Menu. The root element of the widget.
  • .ais-Menu--noRefinement. The root element of the widget with no refinement.
  • .ais-Menu-list. The list of all menu items.
  • .ais-Menu-item. The menu list item.
  • .ais-Menu-item--selected. The selected menu list item.
  • .ais-Menu-link. The clickable menu element.
  • .ais-Menu-label. The label of each item.
  • .ais-Menu-count. The count of values for each item.
  • .ais-Menu-showMore. The button used to display more categories.
  • .ais-Menu-showMore--disabled. The disabled button used to display more categories.
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?
  • canToggleShowMore: boolean. Is show-more possible?
  • isShowingMore: boolean. Is show-more enabled?
  • refine: (value: string) => void. The function to select a refinement.
  • createURL: (value: string) => string. The function to return a link for this refinement.
  • sendEvent: (eventType: 'click', facetValue: string) => void. The function to send click events.
    • The view event is automatically sent when the facets are rendered.
    • The click event is automatically sent when refine is called.
    • You can learn more about the insights middleware.
Where each item is an object containing:
  • value: string. The value of the menu item.
  • label: string. The human-readable value of the menu item.
  • count: number. The number of results matched after a refinement is applied.
  • isRefined: boolean. Indicates if the refinement is applied.
Vue
showMoreLabel
The slot to override the DOM output for the label of the “Show more” button.Scope
  • isShowingMore: boolean. Is show-more enabled?
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 with href attributes to allow search engine bots to follow links.
  • Use semantic HTML and include structured data when relevant.
For more guidance, see the SEO checklist.
Last modified on July 10, 2026