React SDK

useFilter

useFilter returns the filter items (current values and options).

Usage

Editable Example
​
Suggestions
    Site search by

    Loading...

    Count aggregate

    Return count aggregate values for a given facet and display them for your users.

    Editable Example
    ​
    Suggestions
      Site search by

      Loading...

      Customizable

      Output from useFilter can be used to customize different interfaces.

      Editable Example
      ​
      Suggestions
        Site search by

        Loading...

        Anatomy

        useFilter returns an object containing the following properties:

        NameTypeDefaultDescription
        optionsOption[]An array of selectable options
        selectedstring[]An array of, or single item for current selected option(s)
        setSelected(values:string) => voidSet the selected option(s)
        multibooleanWhether the filter allows multiple selections
        reset() => voidReset the current state to the initial state

        Parameters

        NameTypeDefaultDescription
        namestringThe name of the filter that you specified in FilterBuilder.
        paramsobjectAdditional options. See details on the below table.

        params

        NameTypeDefaultDescription
        sort'alpha' | 'count' | 'none''alpha''alpha' stands for 'alphanumeric' meaning to sort the items based on label alphabetically, 'count' to sort based on count, 'none' to skip the sorting process.
        sortAscendingbooleanSort the records in descending order.
        includesstring[]If the list is set, select the items of the list from the filter options.
        excludesstring[]If the list is set, eliminate the items of the list from the filter options.
        prefixFilterstringOnly include the filter options that starts with the prefix.