Signature
Import
About this widget
TherangeSlider
widget provides a user-friendly way to filter the results,
based on a single numeric range.
Requirements
Theattribute
provided to the widget must be in attributes for faceting,
either on the dashboard or using the attributesForFaceting
parameter with the API.
The values of the attribute must be numbers, not strings.
Examples
JavaScript
Options
The CSS Selector or
HTMLElement
to insert the widget into.The name of the attribute in the record.
JavaScript
The minimum value for the input.
When not provided, the minimum value is automatically computed by Algolia from the data in the index.
JavaScript
The maximum value for the input.
When not provided, the maximum value is automatically computed by Algolia from the data in the index.
JavaScript
The number of digits after the decimal point to use.Use a negative value to round values to powers of 10.For example, a precision of -2 would round a number to the nearest hundred,
while a precision of -3 would round it to the nearest thousand.
JavaScript
The number of steps between each handle move.
JavaScript
Whether to show slider pips.
JavaScript
Whether to show tooltips.
The default tooltips show the raw value.
You can also provide an object with a
format
function.The CSS classes you can override:
root
. The root element of the widget.handle
. The handle elements.lowerHandle
. The handle for the minimum value.upperHandle
. The handle for the maximum value.tooltip
. The tooltip elements.
JavaScript
HTML output
HTML
Customize the UI with connectRange
If you want to create your own UI of the rangeSlider
widget, you can use connectors.
This connector is also used to build the
rangeInput
widget.connectRange
, you can import it with the declaration relevant to how you installed InstantSearch.js.
JavaScript
Create a render function
This rendering function is called before the first search (init
lifecycle step)
and each time results come back from Algolia (render
lifecycle step).
JavaScript
Rendering options
The current value for the refinement,
with
start[0]
as the minimum value and start[1]
as the maximum value.JavaScript
The current available value for the range.
JavaScript
Indicates if search state can be refined.
JavaScript
Sets a range to filter the results on.
Both values are optional, and default to the higher and lower bounds.
You can use
undefined
to remove a previously set bound or to set an infinite bound.JavaScript
The function to send
click
events.
The click
event is automatically sent when refine
is called.
To learn more, see the insights
middleware.eventType: 'click'
facetValue: string
JavaScript
All original widget options forwarded to the render function.
JavaScript
Create and instantiate the custom widget
First, create your custom widgets using a rendering function. Then, instantiate them with parameters. There are two kinds of parameters you can pass:- Instance parameters. Predefined options that configure Algolia’s behavior.
- Custom parameters. Parameters you define to make the widget reusable and adaptable.
renderFunction
, both instance and custom parameters are accessible through connector.widgetParams
.
JavaScript
Instance options
The name of the attribute in the record.
JavaScript
The minimum value for the input.
When not provided, the minimum value is automatically computed by Algolia from the data in the index.
JavaScript
The maximum value for the input.
When not provided, the maximum value is automatically computed by Algolia from the data in the index.
JavaScript
The number of digits after the decimal point to use.Use a negative value to round values to powers of 10.For example, a precision of -2 would round a number to the nearest hundred,
while a precision of -3 would round it to the nearest thousand.
JavaScript