Signature
Import
- Component
- Plugin
To ensure optimal bundle sizes,
see Optimize build size.
Vue
About this widget
Useais-trending-items to display items that are gaining popularity based on conversion events.
By default, it retrieves trending items across the index.
To retrieve trending items within a specific category or other facet value,
set facet-name and facet-value.
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
The attribute to get recommendations for.
Use this prop with
facet-value.Vue
string
The value for the targeted facet name.
Use this prop with
facet-name.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 that receives the items before the widget displays them.
It returns a new array with the same “shape” as the original.
This is helpful when transforming or reordering items.
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-TrendingItems. The widget’s root element.ais-TrendingItems--empty. The root element without results.ais-TrendingItems-title. The widget’s title element.ais-TrendingItems-container. The container of the list element.ais-TrendingItems-list. The list of recommendations.ais-TrendingItems-item. The list item.
carousel layout, the ais-TrendingItems-list and ais-TrendingItems-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 “Trending items” 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