Skip to main content
Signature

Explore example code

Browse the Filter Numeric Range example code on GitHub.

About this widget

Filter Numeric Range is a filtering component made to filter between two numeric values. The most common interface for this is a slider.

Examples

Instantiate a NumberRangeConnector and launch an initial search on its searcher.
Swift

Parameters

searcher
HitsSearcher
required
The Searcher that handles your searches.
filterState
FilterState
required
The FilterState that holds your filters.
attribute
Attribute
required
The attribute to filter.
interactor
NumberRangeInteractor<Number>
required
default: .init()
The logic applied to the numeric range.
bounds
ClosedRange<Number>?
default: nil
The nounds limiting the max and the min value of the range.
range
ClosedRange<Number>
default: nil
The initial range value.
operator
RefinementOperator
default: .and
Whether the filter is added to a conjuncitve(and) or a disjuncitve (or) group in the filter state.
groupName
String
default: The value of the `attribute` parameter
Filter group name in the FilterState
controller
NumberRangeController
default: nil
The Controller interfacing with a concrete number range view.

Low-level API

If you want to fully control the Filter Numeric Range components and connect them manually, you can use the following components:
  • Searcher. The Searcher that handles your searches.
  • FilterState. The current state of the filters.
  • NumberRangeInteractor. The logic applied to the numeric ranges.
  • NumberRangeController. The controller that interfaces with a concrete numeric range view.
Swift

Customizing your view

If you want to use a third-party input view, or you want to introduce some custom behavior to the already provided UIKit component, you can create your own controller conforming to the NumberRangeController protocol.

Protocol

func setBounds(_ bounds: ClosedRange<Double>): Function called when the minimum and maximum of numeric filter view have been defined. var onRangeChanged: ((ClosedRange<Double>) -> Void)? Closure to call when new bounds is set for the numeric range filter.

Example

Suppose you have a range slider control providing the following API:
Swift
Then, you could implement the NumberRangeController including this control as follows:
Swift

SwiftUI

InstantSearch provides the NumberRangeObservableController data model, which is an implementation of the NumberRangeController protocol adapted for usage with SwiftUI. NumberRangeObservableController must be connected to the NumberRangeConnector or NumberRangeConnector like any other NumberRangeController implementation. The example of the number range view using two Stepper components provided by SwiftUI.
Swift
If you prefer to create a custom SwiftUI view that presents the numeric range, you can directly use the NumberRangeObservableController as a data model. It provides range and bounds properties to streamline the design process of your custom SwiftUI view.
Last modified on July 10, 2026