ais-hits-per-page
<ais-hits-per-page :items="object[]" // Optional parameters :transform-items="function" :class-names="object" />
1
2
3
4
5
6
7
8
9
import { AisHitsPerPage } from 'vue-instantsearch';
// Use 'vue-instantsearch/vue3/es' for Vue 3
export default {
components: {
AisHitsPerPage
},
// ...
};
1. Follow additional steps in Optimize build size to ensure your code is correctly bundled.
2. This imports all the widgets, even the ones you don’t use. Read the Getting started guide for more information.
About this widget
The ais-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
1
2
3
4
5
6
<ais-hits-per-page
:items="[
{ label: '8 hits per page', value: 8, default: true },
{ label: '16 hits per page', value: 16 },
]"
/>
Props
Parameter | Description | ||
---|---|---|---|
items
|
type: object[]
Required
The list of available options, with each item:
|
||
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 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
|
|||
class-names
|
type: object
default: {}
Optional
The CSS classes you can override:
|
||
Copy
|
Customize the UI
Parameter | Description | ||
---|---|---|---|
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
|
HTML output
1
2
3
4
5
6
<div class="ais-HitsPerPage">
<select class="ais-HitsPerPage-select">
<option class="ais-HitsPerPage-option" value="8">8 per page</option>
<option class="ais-HitsPerPage-option" value="16">16 per page</option>
</select>
</div>