Signature
Import
- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
About this widget
Theais-hits-per-page
widget displays a select element to let users change the number of displayed hits.
If you only want to configure the number of hits per page without displaying a widget,
you can use the ais-configure
widget with the hitsPerPage
search parameter.
Examples
Vue
Props
The list of available options, with each item:
label: string
. The label to display in the option.value: number
. The number of hits to display per page.default: boolean
. Whether it’s the default hits per page on first search.
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
.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-HitsPerPage
. The root of the widget.ais-HitsPerPage-select
. The select element.ais-HitsPerPage-option
. The option element of the select.
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.canRefine: boolean
. Whether a refinement can be applied.refine: (value: number) => void
. The function to call with the next value of hits per page.
object
containing:label: string
. The label to display in the option.value: number
. The number of hits to display per page.isRefined: boolean
. Indicates if the item is the current refined value.
Vue
HTML output
HTML