Skip to main content
Signature

Explore example code

Browse the Current Filters example code on GitHub.

About this widget

Shows each currently active in aFilterState and lets users remove it.

Examples

Instantiate a CurrentFiltersConnector.
Swift

Parameters

FilterState
required
The FilterState that holds your filters.
Set<FilterGroup.ID>?
required
default: nil
When specified, only display current filters matching these filter group ids.
CurrentFiltersInteractor
required
default: .init()
The logic applied to the current filters.
CurrentFiltersController
default: nil
The Controller interfacing with a concrete current filters view.
Presenter<Filter, Output>
default: nil
The Presenter defining how filters appears in the controller.

Presenter

(Filter) -> String
The presenter that defines the way you want to display a filter.
Swift

Low-level API

If you want to fully control the Current Filters components and connect them manually, you can use the following components:
  • CurrentFiltersInteractor. The logic for current filters in the FilterState.
  • FilterState. The current state of the filters.
  • CurrentFiltersController. The controller that interfaces with a concrete current filter view.
  • Presenter. Optional. The presenter that defines the way you want to display a filter.
Swift

Customizing your view

The controllers provided by default, like the CurrentFilterListTableController work well when you want to use native UIKit with their default behavior. If you want to use another component (other than a UITableView) such as a UICollectionView, 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 CurrentFiltersController protocol.

Protocol

func setItems(_ item: [FilterAndID]): Function called when current filters are refreshed and need to be updated. Note that FilterAndID is a struct that contains the filter, its ID, and the text representation of the filter var onRemoveItem: ((FilterAndID) -> Void)?: Closure to call when a “remove filter” intention is detected on the corresponding current filter. func reload(): Function called when the view needs to reload itself with new data.

Example

Swift

SwiftUI

InstantSearch provides the CurrentFiltersObservableController data model, which is an implementation of the CurrentFiltersController protocol adapted for usage with SwiftUI. CurrentFiltersObservableController must be connected to the CurrentFiltersConnector or CurrentFiltersConnector like any other CurrentFiltersController implementation. The example of the current filters view presenting the grouped filters.
Swift
If you prefer to create a custom SwiftUI view that presents each , use the CurrentFiltersObservableController as a data model. It provides the filters property along with toggle and isSelected functions to streamline the design process of your custom SwiftUI view.
Last modified on July 22, 2026