widgets rangeInput

Edit this page

Description

The range input widget allows a user to select a numeric range using a minimum and maximum input.

Requirements

The attribute passed to attributeName must be declared as an attribute for faceting in your Algolia settings.

The values inside this attribute must be JavaScript numbers (not strings).

Live example

You can find an example at the end of the page or a live example in our widget showcase.

Usage

Usage
const search = instantsearch( /* parameters */ );

const widget = instantsearch.widgets.rangeInput({ container: string|HTMLElement, attributeName: string, min: [number], max: [number], precision: [number], cssClasses: [RangeInputClasses], templates: [RangeInputTemplates], labels: [RangeInputLabels], autoHideContainer: [boolean], collapsible: [boolean], }: RangeInputWidgetOptions);
search.addWidget(widget);

Options

RangeInputWidgetOptions

  • containerstring|HTMLElement

    Valid CSS Selector as a string or DOMElement.

  • attributeNamestring

    Name of the attribute for faceting.

  • min[number]

    Minimal slider value, default to automatically computed from the result set.

  • max[number]

    Maximal slider value, defaults to automatically computed from the result set.

  • precision[number]
    Default value: 0

    Number of digits after decimal point to use.

  • cssClasses[RangeInputClasses]

    CSS classes to add.

  • templates[RangeInputTemplates]

    Templates to use for the widget.

  • labels[RangeInputLabels]

    Labels to use for the widget.

  • autoHideContainer[boolean]
    Default value: true

    Hide the container when no refinements available.

  • collapsible[boolean]
    Default value: false

    Hide the widget body and footer when clicking on header.

RangeInputClasses

  • root[string|Array<string>]

    CSS class to add to the root element.

  • header[string|Array<string>]

    CSS class to add to the header element.

  • body[string|Array<string>]

    CSS class to add to the body element.

  • form[string|Array<string>]

    CSS class to add to the form element.

  • fieldset[string|Array<string>]

    CSS class to add to the fieldset element.

  • labelMin[string|Array<string>]

    CSS class to add to the min label element.

  • inputMin[string|Array<string>]

    CSS class to add to the min input element.

  • separator[string|Array<string>]

    CSS class to add to the separator of the form.

  • labelMax[string|Array<string>]

    CSS class to add to the max label element.

  • inputMax[string|Array<string>]

    CSS class to add to the max input element.

  • submit[string|Array<string>]

    CSS class to add to the submit button of the form.

RangeInputTemplates

  • header[string|function]
    Default value: ""

    Header template.

RangeInputLabels

  • separator[string]
    Default value: "to"

    Separator label, between min and max.

  • submit[string]
    Default value: "Go"

    Button label.

Widget

  • render[function]

    Called after each search response has been received

  • getConfiguration[function]

    Let the widget update the configuration of the search with new parameters

  • init[function]

    Called once before the first search

Example

search.addWidget(
  instantsearch.widgets.rangeInput({
    container: '#range-input',
    attributeName: 'price',
    labels: {
      separator: 'to',
      submit: 'Go'
    },
    templates: {
      header: 'Price'
    }
  })
);

Can't find what you are looking for? Open an issue, we'll get back to you.