This is the React InstantSearch v7 documentation.
If you’re upgrading from v6, see the upgrade guide.
If you were using React InstantSearch Hooks,
this v7 documentation applies—just check for necessary changes.
To continue using v6, you can find the archived documentation.
Signature
Import
JavaScript
About this Hook
Use this React Hook to filter search results within a numeric range. You can build custom slider components with this Hook. To display a number range input, use theRangeInput widget instead.
Requirements
Theattribute provided to this Hook must be a facet,
which you can declare
in the dashboard
or using the attributesForFaceting index setting.
The attribute values must be numbers, not strings.
Examples
Range slider with React Spectrum
Range slider with Radix UI
Parameters
The name of the numeric attribute in your Algolia records to use for refining the search.
JavaScript
The minimum value for the range.If not set,
Algolia determines it based on the lowest value of the
attribute prop.JavaScript
The maximum value for the range.
If not set,
Algolia determines it based on the highest value of the
attribute prop.JavaScript
The number of decimal places to use when rounding values.
Use negative values to round to powers of 10.
JavaScript
Returns
The selected range for the refinement,
where
start[0] is the lower bound and start[1] is the higher bound.The possible bounds based on the attribute’s values.
Whether the search can be refined.
Sets the range used to filter results.
Use
undefined to remove a bound or allow it to be unbounded.
Both values are optional and default to the upper and lower bounds.Sends an event to the Insights API.