The range input widget allows a user to select a numeric range using a minimum and maximum input.
The attribute passed to attribute
must be declared as an
attribute for faceting
in your Algolia settings.
The values inside this attribute must be JavaScript numbers (not strings).
You can find an example at the end of the page or a live example in our widget showcase.
const search = instantsearch( /* parameters */ );
const widget = instantsearch.widgets.rangeInput({
container: string|HTMLElement,
attribute: string,
min: [number],
max: [number],
precision: [number],
templates: [RangeInputTemplates],
cssClasses: [RangeInputClasses],
}: RangeInputWidgetOptions);
search.addWidget(widget);
string|HTMLElement
Valid CSS Selector as a string or DOMElement.
string
Name of the attribute for faceting.
[number]
Minimal slider value, default to automatically computed from the result set.
[number]
Maximal slider value, defaults to automatically computed from the result set.
[number]
0
Number of digits after decimal point to use.
[RangeInputTemplates]
Labels to use for the widget.
[RangeInputClasses]
CSS classes to add.
[string]
"to"
The label of the separator, between min and max.
[string]
"Go"
The label of the submit button.
[string|Array<string>]
CSS class to add to the root element.
[string|Array<string>]
CSS class to add to the root element when there’s no refinements.
[string|Array<string>]
CSS class to add to the form element.
[string|Array<string>]
CSS class to add to the label element.
[string|Array<string>]
CSS class to add to the input element.
[string|Array<string>]
CSS class to add to the min input element.
[string|Array<string>]
CSS class to add to the max input element.
[string|Array<string>]
CSS class to add to the separator of the form.
[string|Array<string>]
CSS class to add to the submit button of the form.
[function]
Called after each search response has been received
[function]
Let the widget update the configuration of the search with new parameters
[function]
Called once before the first search
search.addWidget(
instantsearch.widgets.rangeInput({
container: '#range-input',
attribute: 'price',
templates: {
separatorText: 'to',
submitText: 'Go'
},
})
);
Can't find what you are looking for? Open an issue, we'll get back to you.