Signature
Import
- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
About this widget
Use theais-related-products widget to display a list of related products and related content.
See also: Set up Algolia Recommend
Examples
Vue
With carousel layout
To display the recommendations as a scrollable carousel, set thelayout prop to carousel.
Vue
Props
string[]
required
The list of object IDs to get recommendations for.
If you specify several object IDs,
you’ll get a single set of aggregated results from the requests, ordered by their score.
Vue
number
The number of recommendations to retrieve.
Depending on the available recommendations and the other request parameters,
the actual number of items may be lower than that.
If you omit
limit or set it to 0, the widget returns all matching recommendations.Vue
number
The threshold for the recommendations confidence score (between 0 and 100).
The widget only returns recommendations with a greater score.
Vue
Omit<SearchParameters, hitsPerPage | length | offset | page>
Search parameters to apply to the recommendation request.
Vue
Omit<SearchParameters, hitsPerPage | length | offset | page>
List of search parameters
to send as an extra set when there aren’t enough recommendations.
Vue
boolean
default:true
Whether to escape HTML tags from recommendations string values.
Vue
function
default:"items => items"
A function to transform or reorder recommendations before the widget displays them.
It returns an array of items with the same structure.
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
'list' | 'carousel'
default:"'list'"
How to display the recommendations:
list. A list of items.carousel. A horizontally scrollable carousel with “Previous” and “Next” navigation buttons.
item slot applies to both layouts.Vue
object
default:"{}"
The CSS classes you can override:
ais-RelatedProducts. The widget’s root element.ais-RelatedProducts--empty. The root element without results.ais-RelatedProducts-title. The widget’s title element.ais-RelatedProducts-container. The container of the list element.ais-RelatedProducts-list. The list of recommendations.ais-RelatedProducts-item. The list item.
carousel layout, the ais-RelatedProducts-list and ais-RelatedProducts-item classes apply to the carousel’s list and items.Vue
Customize the UI
The slot to override the complete DOM output of the widget.
The widget only uses this slot if you don’t provide any other slot.Scope
items: object[]. The recommendations.sendEvent: (eventType, hit, eventName) => void. The function to sendclickorconversionevents.
Vue
The slot to override the DOM output of each recommendation.
If you don’t provide it, the widget displays the recommendation as a JSON string.Scope
item: object. A single recommendation with all its attributes.sendEvent: (eventType, hit, eventName) => void. The function to sendclickorconversionevents.
Vue
The slot to override the DOM output of the title header.
The widget doesn’t render the header when there are no recommendations.
If you don’t provide it, the widget displays “Related products” as the title.Scope
items: object[]. The recommendations.translations: object. The widget’s translations, such astitle.classNames: object. The widget’s CSS classes, such astitle.
Vue
The slot to override the DOM output when there are no recommendations.
If you don’t provide it, the widget displays “No results”.
Vue
HTML output
HTML