RatingMenu | React InstantSearch V6 (Deprecated)
Signature
<RatingMenu attribute={string} // Optional parameters defaultRefinement={object} min={number} max={number} translations={object} />
About this widget
The RatingMenu
lets the user refine search results by clicking on stars. The stars are based on the selected attribute.
Requirements
The attribute provided to the widget must be in attributes for faceting, either on the dashboard) or using attributesForFaceting
with the API.
The attribute values must be integers, not strings nor floats. If your dataset includes float values, the widget returns only exact numerical matches. For example, if a user selects “4 [stars] & Up”, we only return records with values such as 4
or 5
, not records with values like 4.5
or 4.7
. If your attribute is a float, we recommend indexing a new attribute with the rounded integer value to use in this widget.
Examples
1
2
3
import { RatingMenu } from 'react-instantsearch-dom';
<RatingMenu attribute="rating" />
Props
attribute
string
The name of the attribute in the record.
1
<RatingMenu attribute="rating" />
defaultRefinement
object
The default state of the widget containing the min
value for the stars.
1
2
3
4
<RatingMenu
// ...
defaultRefinement={{ min: 2 }}
/>
min
number
The minimum value for the rating. When not provided, the minimum value is automatically computed by Algolia from the data in the index.
1
2
3
4
<RatingMenu
// ...
min={2}
/>
max
number
The maximum value for the rating. When not provided, the maximum value is automatically computed by Algolia from the data in the index.
1
2
3
4
<RatingMenu
// ...
max={4}
/>
translations
object
A mapping of keys to translation values.
ratingLabel
: the label for the value that suffix the list of stars.
1
2
3
4
5
6
<RatingMenu
// ...
translations={{
ratingLabel: '& Up',
}}
/>