Skip to Content

FilterList

FilterList renders filter controls for an OSDK object type, optionally scoped to an object set, backed by aggregations. It reports the combined where clause, and the filtered object set when you pass objectSet.

Prerequisites

Before using FilterList, make sure you have completed the library setup described in Prerequisites, including:

  • Installing the required dependencies
  • Wrapping your app with OsdkProvider
  • Adding the CSS imports

Import

import { FilterList } from "@osdk/react-components/filter-list";

Basic Usage

@my-app/sdk is a placeholder for your generated SDK package. ./client is the file in your app where you exported the OSDK client returned by createClient(...). Replace both with the actual paths in your project.

The simplest way to use FilterList is with an objectSet and a few filter definitions:

import { Employee } from "@my-app/sdk";
import { FilterList } from "@osdk/react-components/filter-list";
import client from "./client";

function EmployeeFilters() {
  return (
    <FilterList
      objectSet={client(Employee)}
      filterDefinitions={[
        {
          type: "PROPERTY",
          key: "department",
          filterComponent: "LISTOGRAM",
        },
        {
          type: "PROPERTY",
          key: "jobTitle",
          filterComponent: "LISTOGRAM",
        },
      ]}
    />
  );
}

Props Reference

Type parameters: Q extends ObjectTypeDefinition

NameTypeDescription
objectTypeQRequired. The object type definition for the objects being filtered. Used for metadata resolution (property types, display names).
objectSetObjectSet<Q>Optional object set to scope aggregation queries. When omitted, aggregations run against the full object type.Required for HAS_LINK and LINKED_PROPERTY filters to work.
filterDefinitionsArray<FilterDefinitionUnion<Q>>The definition for all supported filter items in the list If not supplied, all filterable properties will be available
defaultFilterStatesMap<string, FilterState>Seeds filter states from external storage, keyed by getFilterKey. Applied over the per-definition defaultFilterState seeds on mount, and FilterList owns the states from then on. Also the state the reset button restores to. Use onFilterStateChanged to persist changes back out. Defaults to undefined (filters seed from their definitions alone).
initialFilterStatesMap<string, FilterState>Deprecated — Rename to defaultFilterStates.
onFilterListChanged(event: FilterChangeEvent<Q>) => voidCalled on filter init and when filter state changes.
onFilterClauseChanged(newClause: WhereClause<Q>) => voidDeprecated — Use onFilterListChanged, whose snapshot reports the clause alongside the filtered ObjectSet. Called whenever the filter clause changes. FilterList owns filter state; this is how you read it out, e.g. to feed an ObjectTable's filter.HAS_LINK and LINKED_PROPERTY filters are not represented in the clause — use onEffectiveObjectSet for those.
onFilterStateChanged(definition: FilterDefinitionUnion<Q>, newState: FilterState) => voidDeprecated — Use onFilterListChanged, which reports every set / clear / reset with an event describing what changed. Called when filter state changes
onEffectiveObjectSet(objectSet: ObjectSet<Q>) => voidDeprecated — Use onFilterListChanged, whose snapshot.filteredObjectSet reports the same filtered set alongside the clause. Called with the filtered ObjectSet whenever filters change. Requires objectSet to be set. HAS_LINK and LINKED_PROPERTY filters apply only here, never through the filter clause.
addFilterMode"controlled" | "uncontrolled"Deprecated — Going away; visibility will always be managed internally. Seed it with isVisible on each filterDefinitions entry and observe changes with onFilterVisibilityChange. Controls how filter visibility (add/remove) is managed.- "uncontrolled" (default): FilterList manages visibility internally. An "Add filter" popover is rendered for filters with isVisible: false, and each visible filter shows a remove button. - "controlled": The consumer manages which filters are visible via filterDefinitions. Filters with isVisible: false are excluded from the rendered list. Defaults to "uncontrolled".
renderAddFilterButton() => React.ReactNodeCustom render function for the "Add filter" button. Customizes the trigger element for the built-in add-filter popover; the popover behavior is handled automatically.
onFilterAdded(filterKey: string, newDefinitions: Array<FilterDefinitionUnion<Q>>) => voidCalled after a filter is shown from the built-in "Add filter" popover.
onFilterRemoved(filterKey: string) => voidCalled after a filter's remove button is clicked, once the filter is hidden and its state cleared.
enableSortingbooleanEnable drag-and-drop reordering of filters. When true, drag handles are rendered and filters can be reordered.Reorder state is managed internally; persist onFilterVisibilityChange to track order across remounts. Defaults to false.
onFilterVisibilityChange(newStates: Array<{ filterKey: string; isVisible: boolean; }>) => voidCalled when filter visibility or ordering changes, i.e. when filters are reordered, added or removed via the built-in show/remove controls, or reset.Visible filters come first, in display order, followed by the hidden ones. Persist this array and feed it back as the order and isVisible of filterDefinitions to make reordering survive a remount.
enableCollapsebooleanWhether the collapse/expand control is available. When false the panel is always expanded, no collapse control is rendered, and collapsed / defaultCollapsed are ignored. Defaults to true.
collapsedbooleanControlled mode. When supplied, this prop is the source of truth for whether the panel is collapsed and the component keeps no internal state; re-render with a new value in response to onCollapsedChange.If both collapsed and defaultCollapsed are provided, collapsed takes precedence. Ignored when enableCollapse is false.
defaultCollapsedbooleanUncontrolled mode. Seeds the panel's internal collapsed state; the component continues to own the state after mount, so later changes to this prop are ignored.If both collapsed and defaultCollapsed are provided, collapsed takes precedence. Ignored when enableCollapse is false. Defaults to false.
onCollapsedChange(collapsed: boolean) => voidCalled whenever the collapsed state changes.
showResetButtonbooleanShow reset filters button in header
onReset() => voidCalled when reset button is clicked
titleReactNodeOptional title to display in the filter list header
titleIconReact.ReactNodeOptional icon to display next to the title
showActiveFilterCountbooleanShow count of active filters in header
showFilteredOutValuesbooleanWhen true, facets render greyed-out count=0 rows for values present in the unfiltered data but excluded by other active filters. Defaults to false.
classNamestringAdditional CSS class name

Filter Definitions

Filter Definition Types

TypeDescription
PROPERTYFilter on a direct property of the object type
KEYWORD_SEARCHFull-text keyword search across objects
CUSTOMCustom filter with user-provided render function
HAS_LINKToggle filter for whether a link exists
LINKED_PROPERTYFilter on a property of a linked object type
STATIC_VALUESFilter on a fixed list of values (no OSDK fetching)

Each filter definition type's fields are documented below.

Property Filter Definition

When using type: "PROPERTY", the definition supports:

Type parameters: Q extends ObjectTypeDefinition, K extends PropertyKeys<Q> = PropertyKeys<Q>, C extends ValidComponentsForPropertyType<PropertyTypeFromKey<Q, K>> = ValidComponentsForPropertyType<PropertyTypeFromKey<Q, K>>

NameTypeDescription
searchFieldbooleanWhen false, the header monocle (search-values icon) is hidden even for filter components that ordinarily support in-filter search. Useful for MULTI_SELECT, which already has its own inline search field. Defaults to true.
idstringOptional unique identifier for stable keying across filter reorders. Set it explicitly when that derived value would collide, e.g. two filters on the same property.This is the key used in defaultFilterStates; getFilterKey(definition) returns it. Defaults to a value derived from the definition (its key, or its link and property names)
isVisiblebooleanControls whether this filter is rendered. When false, the filter is hidden but its state is preserved. Defaults to true.
type"PROPERTY"Required. Discriminator for filter definition type
keyKRequired. The property key to filter on
labelstringDisplay label for the filter
filterComponentCRequired. The filter component type to render Must be compatible with the property type derived from the key, see ValidComponentsForPropertyType
defaultFilterStateFilterStateByComponentType[C]Seeds the filter's state on mount, FilterList owns the state from then on Defaults to undefined (filter starts empty).
filterStateFilterStateByComponentType[C]Deprecated — Rename to defaultFilterState.
colorMapRecord<string, string>Maps filter values to colors for visual differentiation. Used by LISTOGRAM (per-row bar colors).
listogramConfig{ displayMode?: "full" | "count" | "minimal"; maxVisibleItems?: number; }Configuration for LISTOGRAM display mode. Only applies when filterComponent is "LISTOGRAM".
renderValue(value: string) => ReactNodeCustom display function for filter values. Replaces the default string display in dropdown items, chips, and listogram rows. When the function returns a string, that string is also used for search matching within filter dropdowns. When it returns a non-string ReactNode, search falls back to the raw value.
showCountbooleanShow aggregation counts next to filter option values. Applies to LISTOGRAM, SINGLE_SELECT, and MULTI_SELECT components. Defaults to true for LISTOGRAM and MULTI_SELECT, false for SINGLE_SELECT.
clickToFilterbooleanWhen true, clicking a bar in the histogram replaces the filter range with that bucket's [min, max]. Only applies to histogram-rendering filter components (NUMBER_RANGE and DATE_RANGE); ignored on other component types.Click replaces the current range — clicking a second bar discards the previous selection. Multi-bucket selection / shift+click union is NOT supported in v1. Defaults to false.

Listogram Configuration

FieldTypeDefaultDescription
displayMode"full" | "count" | "minimal""full"full: bar + count, count: count only, minimal: label only
maxVisibleItemsnumber5Number of items shown before "View all" link appears

Keyword Search Filter Definition

When using type: "KEYWORD_SEARCH", the definition supports:

Type parameters: Q extends ObjectTypeDefinition, K extends StringPropertyKeys<Q> = StringPropertyKeys<Q>

NameTypeDescription
searchFieldbooleanWhen false, the header monocle (search-values icon) is hidden even for filter components that ordinarily support in-filter search. Useful for MULTI_SELECT, which already has its own inline search field. Defaults to true.
idstringOptional unique identifier for stable keying across filter reorders. Set it explicitly when that derived value would collide, e.g. two filters on the same property.This is the key used in defaultFilterStates; getFilterKey(definition) returns it. Defaults to a value derived from the definition (its key, or its link and property names)
isVisiblebooleanControls whether this filter is rendered. When false, the filter is hidden but its state is preserved. Defaults to true.
type"KEYWORD_SEARCH"Required.
properties"all" | K[]Required. Properties to search within - "all": Search all string properties - K[]: Search specific string properties
labelstring
defaultFilterStateKeywordSearchFilterStateSeeds the filter's state on mount, FilterList owns the state from then on Defaults to undefined (filter starts empty).
filterStateKeywordSearchFilterStateDeprecated — Has no effect, remove it.

When using type: "HAS_LINK", the definition supports:

Type parameters: Q extends ObjectTypeDefinition, L extends LinkNames<Q> = LinkNames<Q>

NameTypeDescription
searchFieldbooleanWhen false, the header monocle (search-values icon) is hidden even for filter components that ordinarily support in-filter search. Useful for MULTI_SELECT, which already has its own inline search field. Defaults to true.
idstringOptional unique identifier for stable keying across filter reorders. Set it explicitly when that derived value would collide, e.g. two filters on the same property.This is the key used in defaultFilterStates; getFilterKey(definition) returns it. Defaults to a value derived from the definition (its key, or its link and property names)
isVisiblebooleanControls whether this filter is rendered. When false, the filter is hidden but its state is preserved. Defaults to true.
type"HAS_LINK"Required.
linkNameLRequired.
labelstring
defaultFilterStateHasLinkFilterStateSeeds the filter's state on mount, FilterList owns the state from then on Defaults to undefined (filter starts empty).
filterStateHasLinkFilterStateDeprecated — Has no effect, remove it.

Link presence has no filter-clause form, so a HAS_LINK filter applies only through onEffectiveObjectSet (it never shows up in onFilterClauseChanged). Pass objectSet to FilterList and feed the emitted set to whatever renders the rows:

{
  type: "HAS_LINK",
  linkName: "manager",   // keeps employees who have a manager
  label: "Has a manager",
}

Toggling the filter's Excluding mode keeps the objects with no linked object instead.

Linked Property Filter Definition

When using type: "LINKED_PROPERTY", the definition supports:

Type parameters: Q extends ObjectTypeDefinition, L extends LinkNames<Q>, LinkedQ extends ObjectTypeDefinition = LinkedType<Q, L>, LinkedK extends PropertyKeys<LinkedQ> = PropertyKeys<LinkedQ>, LinkedC extends ValidComponentsForPropertyType<PropertyTypeFromKey<LinkedQ, LinkedK>> = ValidComponentsForPropertyType<PropertyTypeFromKey<LinkedQ, LinkedK>>

NameTypeDescription
searchFieldbooleanWhen false, the header monocle (search-values icon) is hidden even for filter components that ordinarily support in-filter search. Useful for MULTI_SELECT, which already has its own inline search field. Defaults to true.
idstringOptional unique identifier for stable keying across filter reorders. Set it explicitly when that derived value would collide, e.g. two filters on the same property.This is the key used in defaultFilterStates; getFilterKey(definition) returns it. Defaults to a value derived from the definition (its key, or its link and property names)
isVisiblebooleanControls whether this filter is rendered. When false, the filter is hidden but its state is preserved. Defaults to true.
type"LINKED_PROPERTY"Required.
linkNameLRequired.
reverseLinkNameLinkNames<LinkedQ>Deprecated — Has no effect, remove it.
linkedPropertyKeyLinkedKRequired.
filterComponentLinkedCThe filter component to render for the linked property. Must be compatible with the linked property's type, see ValidComponentsForPropertyType.Required in practice — a definition that sets neither this nor linkedFilterComponent renders as unsupported.
linkedFilterComponentLinkedCDeprecated — Rename to filterComponent.
defaultFilterStateFilterStateByComponentType[LinkedC]Seeds the state of the filter on the linked property. FilterList owns the state from then on. onFilterStateChanged fires with the wrapper. Defaults to undefined (filter starts empty).
defaultLinkedFilterStateFilterStateByComponentType[LinkedC]Deprecated — Rename to defaultFilterState.
linkedFilterStateFilterStateByComponentType[LinkedC]Deprecated — Has no effect, remove it.
filterStateLinkedPropertyFilterState<FilterStateByComponentType[LinkedC]>Deprecated — Has no effect, remove it.
labelstring
showCountbooleanShow aggregation counts next to filter option values. Applies to LISTOGRAM, SINGLE_SELECT, and MULTI_SELECT linked components. Defaults to true for LISTOGRAM and MULTI_SELECT, false for SINGLE_SELECT.
renderValue(value: string) => ReactNodeCustom display function for filter values. Replaces the default string display in dropdown items, chips, and listogram rows. When the function returns a string, that string is also used for search matching within filter dropdowns. When it returns a non-string ReactNode, search falls back to the raw value.

How LINKED_PROPERTY filters

Like HAS_LINK, a LINKED_PROPERTY filter applies only through onEffectiveObjectSet — it never appears in onFilterClauseChanged. FilterList derives a count of the linked objects matching the filter (withProperties({ …: (base) => base.pivotTo(linkName).where(...).aggregate("$count") })) and keeps the rows whose count is above zero:

{
  type: "LINKED_PROPERTY",
  linkName: "manager",          // Employee → Manager
  linkedPropertyKey: "fullName",
  filterComponent: "MULTI_SELECT",
}

reverseLinkName is deprecated: filtering counts linked objects instead of pivoting back to the source type, so no back-link is needed. Definitions that still pass it keep working — the value is ignored.

Custom Filter Definition

When using type: "CUSTOM", the definition supports:

Type parameters: Q extends ObjectTypeDefinition, State extends BaseFilterState = CustomFilterState

NameTypeDescription
searchFieldbooleanWhen false, the header monocle (search-values icon) is hidden even for filter components that ordinarily support in-filter search. Useful for MULTI_SELECT, which already has its own inline search field. Defaults to true.
idstringOptional unique identifier for stable keying across filter reorders. Set it explicitly when that derived value would collide, e.g. two filters on the same property.This is the key used in defaultFilterStates; getFilterKey(definition) returns it. Defaults to a value derived from the definition (its key, or its link and property names)
isVisiblebooleanControls whether this filter is rendered. When false, the filter is hidden but its state is preserved. Defaults to true.
type"CUSTOM"Required.
keystringRequired. Unique key for this custom filter
labelstring
filterComponent"CUSTOM"Required.
defaultFilterStateStateSeeds the filter's state on mount, FilterList owns the state from then on Defaults to undefined (filter starts empty).
filterStateStateDeprecated — Rename to defaultFilterState.
renderInput(props: CustomFilterInputRendererProps<Q, State>) => ReactNodeRender the input portion of the filter Used when rendering within a filter item wrapper
renderItem(props: CustomFilterItemRendererProps<Q, State>) => ReactNodeRender the complete filter item Used when you need full control over the item appearance
toWhereClause(state: State) => WhereClause<Q> | undefinedRequired. Convert filter state to a WhereClause for filtering Required for the filter to affect the object set

Static Values Filter Definition

When using type: "STATIC_VALUES", the definition supports:

Type parameters: Q extends ObjectTypeDefinition, C extends StaticValuesComponentType = StaticValuesComponentType

NameTypeDescription
searchFieldbooleanWhen false, the header monocle (search-values icon) is hidden even for filter components that ordinarily support in-filter search. Useful for MULTI_SELECT, which already has its own inline search field. Defaults to true.
idstringOptional unique identifier for stable keying across filter reorders. Set it explicitly when that derived value would collide, e.g. two filters on the same property.This is the key used in defaultFilterStates; getFilterKey(definition) returns it. Defaults to a value derived from the definition (its key, or its link and property names)
isVisiblebooleanControls whether this filter is rendered. When false, the filter is hidden but its state is preserved. Defaults to true.
type"STATIC_VALUES"Required.
keystringRequired. Key used for state management and auto WHERE clause generation. When toWhereClause is not provided, this is used as the property key in the generated WHERE clause.
labelstringDisplay label for the filter
filterComponentCRequired. The filter component type to render
defaultFilterStateFilterStateByComponentType[C]Seeds the filter's state on mount, FilterList owns the state from then on Defaults to undefined (filter starts empty).
filterStateFilterStateByComponentType[C]Deprecated — Rename to defaultFilterState.
valuesstring[]Required. The static list of values to display in the filter component. These are rendered directly without OSDK aggregation.
renderValue(value: string) => ReactNodeCustom display function for filter values. Replaces the default string display in dropdown items, chips, and listogram rows. When the function returns a string, that string is also used for search matching within filter dropdowns. When it returns a non-string ReactNode, search falls back to the raw value.
showCountbooleanShow aggregation counts next to filter option values. Applies to LISTOGRAM, SINGLE_SELECT, and MULTI_SELECT components. Defaults to true for LISTOGRAM and MULTI_SELECT, false for SINGLE_SELECT.
colorMapRecord<string, string>Maps filter values to colors for visual differentiation. Used by LISTOGRAM (per-row bar colors).
listogramConfig{ displayMode?: "full" | "count" | "minimal"; maxVisibleItems?: number; }Configuration for LISTOGRAM display mode. Only applies when filterComponent is "LISTOGRAM".
toWhereClause(state: FilterState) => WhereClause<Q> | undefinedOptional custom WHERE clause generator. When provided, this is used instead of auto-generating a WHERE clause from the key and filter state.

Filter Components

When using type: "PROPERTY" or type: "LINKED_PROPERTY", specify a filterComponent:

ComponentBest ForState Type
LISTOGRAMCategorical data with bar chartEXACT_MATCH
SINGLE_SELECTSingle value dropdownSELECT
MULTI_SELECTMulti-select dropdown with searchSELECT
TEXT_TAGSTag-based input with suggestionsEXACT_MATCH
CONTAINS_TEXTFree-text search on a propertyCONTAINS_TEXT
NUMBER_RANGEMin/max range slider for numbersNUMBER_RANGE
DATE_RANGEDate range pickerDATE_RANGE
TOGGLEBoolean on/off toggleTOGGLE
SINGLE_DATESingle date pickerSELECT
MULTI_DATEMultiple date pickerSELECT
TIMELINEDate range with start/endTIMELINE

Examples

Combining with ObjectTable

FilterList owns its filter state. Read the clause out with onFilterClauseChanged and pass it to ObjectTable:

import { Employee } from "@my-app/sdk";
import type { WhereClause } from "@osdk/api";
import { FilterList } from "@osdk/react-components/filter-list";
import { ObjectTable } from "@osdk/react-components/object-table";
import { useMemo, useState } from "react";
import client from "./client";

function EmployeeDashboard() {
  const [filterClause, setFilterClause] = useState<
    WhereClause<typeof Employee>
  >({});
  const objectSet = useMemo(() => client(Employee), []);

  return (
    <div style={{ display: "flex", gap: 16, height: 600 }}>
      <div style={{ width: 320, flexShrink: 0 }}>
        <FilterList
          objectType={Employee}
          objectSet={objectSet}
          filterDefinitions={[
            {
              type: "PROPERTY",
              key: "department",
              filterComponent: "LISTOGRAM",
            },
            { type: "PROPERTY", key: "team", filterComponent: "LISTOGRAM" },
            {
              type: "PROPERTY",
              key: "fullName",
              filterComponent: "CONTAINS_TEXT",
            },
          ]}
          title="Employee Filters"
          showResetButton={true}
          showActiveFilterCount={true}
          enableSorting={true}
          onFilterClauseChanged={setFilterClause}
        />
      </div>
      <div style={{ flex: 1 }}>
        <ObjectTable objectType={Employee} filter={filterClause} />
      </div>
    </div>
  );
}

Reading everything from one callback

onFilterListChanged reports the state the list mounted with and every change after it — a filter set, a filter removed, or a reset — as an event with a reason (what happened) and a snapshot (everything derived from the resulting state), so you don't need to wire up onFilterStateChanged, onFilterClauseChanged and onEffectiveObjectSet separately and reconcile their firings:

import type { FilterChangeEvent } from "@osdk/react-components/filter-list";

<FilterList
  objectType={Employee}
  objectSet={objectSet}
  filterDefinitions={filterDefinitions}
  onFilterListChanged={(event: FilterChangeEvent<typeof Employee>) => {
    // `snapshot` is always present, whatever the reason:
    // event.snapshot.filterClause      — combined clause for all active filters
    // event.snapshot.filteredObjectSet — `objectSet` filtered by all active filters
    setFilterClause(event.snapshot.filterClause);

    // `event.reason.type` says what happened, and which extra fields you get:
    switch (event.reason.type) {
      case "FILTER_LIST_INITIALIZED":
        break;
      case "FILTER_STATE_CHANGED":
        persist(event.reason.filterKey, event.reason.newState);
        break;
      case "FILTER_REMOVED":
        forget(event.reason.filterKey);
        break;
      case "FILTER_LIST_RESET":
        forgetAll();
        break;
    }
  }}
/>;
event.reason.typeExtra fieldsFires when
"FILTER_LIST_INITIALIZED"—The list mounted, once, before any interaction
"FILTER_STATE_CHANGED"filterKey, newStateThe user changed a filter's value
"FILTER_REMOVED"filterKeyA filter was removed from the list
"FILTER_LIST_RESET"—The reset button restored the mount state

filteredObjectSet is undefined when no objectSet prop is supplied.

"FILTER_LIST_INITIALIZED" reports the state seeded from defaultFilterStates and from each definition's defaultFilterState, so the initial clause and filtered ObjectSet arrive without waiting for a first interaction. If you only care about the current state and not what caused it, ignore reason — every snapshot carries the full filterClause and filteredObjectSet:

onFilterListChanged={(event) => setFilterClause(event.snapshot.filterClause)}

Changes are reported as they happen, with no debounce, so an analytics handler sees every distinct interaction. Free-text and range inputs debounce their own keystrokes, so typing reports once per pause rather than once per character. If you need coarser batching than that — one network request per burst, say — debounce your own handler.

Add/Remove Filters (Uncontrolled Mode)

Use addFilterMode="uncontrolled" with isVisible: false on some filters to let users add and remove filters dynamically:

const filterDefinitions = [
  {
    type: "PROPERTY",
    key: "department",
    label: "Department",
    filterComponent: "LISTOGRAM",
  },
  {
    type: "PROPERTY",
    key: "team",
    label: "Team",
    filterComponent: "LISTOGRAM",
  },
  {
    type: "PROPERTY",
    key: "fullName",
    label: "Full Name",
    filterComponent: "CONTAINS_TEXT",
    isVisible: false,
  },
  {
    type: "PROPERTY",
    key: "startDate",
    label: "Start Date",
    filterComponent: "DATE_RANGE",
    isVisible: false,
  },
];

<FilterList
  objectSet={client(Employee)}
  filterDefinitions={filterDefinitions}
  addFilterMode="uncontrolled"
  showResetButton={true}
/>;

Filters marked isVisible: false appear in the "Add filter" popover. Users can add them to the list and remove visible filters via the close button. Reset restores the original visibility.

Removable Filters (Controlled Mode)

When addFilterMode="controlled" and onFilterRemoved is provided, each filter shows a remove button on hover. The consumer manages the definitions array:

const [definitions, setDefinitions] = useState(filterDefinitions);

const handleFilterRemoved = (filterKey) => {
  setDefinitions(prev => prev.filter(def => def.key !== filterKey));
};

<FilterList
  objectSet={client(Employee)}
  filterDefinitions={definitions}
  addFilterMode="controlled"
  onFilterRemoved={handleFilterRemoved}
  title="Removable Filters"
/>;

Prefiltered ObjectSet

Pass a .where() objectSet to scope filter dropdown values. For example, to only show Engineering employees:

import { Employee } from "@my-app/sdk";
import { FilterList } from "@osdk/react-components/filter-list";
import { useMemo } from "react";
import client from "./client";

function EngineeringFilters() {
  const engineeringSet = useMemo(
    () => client(Employee).where({ department: "Engineering" }),
    [],
  );

  return (
    <FilterList
      objectSet={engineeringSet}
      filterDefinitions={[
        { type: "PROPERTY", key: "jobTitle", filterComponent: "LISTOGRAM" },
        { type: "PROPERTY", key: "location", filterComponent: "LISTOGRAM" },
      ]}
    />
  );
}

The filter dropdowns will only show job titles and locations that exist within the Engineering department.

Keyword Search Filter

Add a full-text search filter that searches across multiple properties:

const filterDefinitions = [
  {
    type: "KEYWORD_SEARCH",
    properties: ["fullName", "department", "jobTitle", "locationCity"],
    label: "Search",
  },
  { type: "PROPERTY", key: "department", filterComponent: "LISTOGRAM" },
  { type: "PROPERTY", key: "locationCity", filterComponent: "LISTOGRAM" },
];

<FilterList
  objectSet={client(Employee)}
  filterDefinitions={filterDefinitions}
/>;

Custom Listogram Colors

Assign colors to specific values in a listogram:

<FilterList
  objectSet={client(Employee)}
  filterDefinitions={[
    {
      type: "PROPERTY",
      key: "department",
      filterComponent: "LISTOGRAM",
      colorMap: {
        Engineering: "#3b82f6",
        Marketing: "#f59e0b",
        Sales: "#10b981",
        Design: "#8b5cf6",
      },
    },
  ]}
/>;

Custom Value Rendering

Use renderValue to customize how filter values are displayed and searched. The returned string replaces the raw value for both display and search matching. This is useful for showing human-readable names instead of IDs:

const USER_NAMES: Record<string, string> = {
  "abc-123": "Alice Smith",
  "def-456": "Bob Jones",
};

<FilterList
  objectSet={client(Task)}
  filterDefinitions={[
    {
      type: "PROPERTY",
      key: "assigneeUserId",
      filterComponent: "LISTOGRAM",
      renderValue: (userId) => USER_NAMES[userId] ?? userId,
    },
  ]}
/>;

renderValue works with LISTOGRAM, SINGLE_SELECT, and MULTI_SELECT filter components. For MULTI_SELECT, it applies to both dropdown items and selected chips. Searching within a filter dropdown matches against the renderValue output.

For best performance, memoize renderValue with useCallback to avoid unnecessary re-renders:

Listogram Display Modes

Control how much detail each listogram row shows:

// "full" (default): checkbox + label + colored bar + count number
// "count": checkbox + label + count number (no bar)
// "minimal": checkbox + label only

<FilterList
  objectSet={client(Employee)}
  filterDefinitions={[
    {
      type: "PROPERTY",
      key: "department",
      filterComponent: "LISTOGRAM",
      listogramConfig: { displayMode: "count" },
    },
  ]}
/>;

Limiting Visible Items

By default, LISTOGRAM filters show at most 5 items with a "View all" link. Override with maxVisibleItems:

<FilterList
  objectSet={client(Employee)}
  filterDefinitions={[
    {
      type: "PROPERTY",
      key: "department",
      filterComponent: "LISTOGRAM",
      listogramConfig: { maxVisibleItems: 10 },
    },
  ]}
/>;

Collapsible Panel

The collapse control is available by default and FilterList owns the collapsed state, so collapsing works with no wiring at all:

<FilterList
  objectSet={client(Employee)}
  title="Filters"
  showActiveFilterCount={true}
  filterDefinitions={[
    { type: "PROPERTY", key: "department", filterComponent: "LISTOGRAM" },
  ]}
/>;

Start collapsed with defaultCollapsed. onCollapsedChange fires in both modes; in uncontrolled mode it is purely a listener on top of the built-in behavior, so the panel keeps collapsing and expanding on its own. Use it when the surrounding layout needs to react:

import { useState } from "react";

function CollapsibleFilters() {
  const [collapsed, setCollapsed] = useState(false);

  return (
    <div style={{ width: collapsed ? "auto" : 280 }}>
      <FilterList
        objectSet={client(Employee)}
        title="Filters"
        defaultCollapsed={false}
        onCollapsedChange={setCollapsed}
        filterDefinitions={[
          { type: "PROPERTY", key: "department", filterComponent: "LISTOGRAM" },
        ]}
      />
    </div>
  );
}

To own the state yourself, pass collapsed instead of defaultCollapsed. That switches the feature into controlled mode: the prop is the source of truth, the component keeps no internal state, and the panel only moves when you re-render with a new value in response to onCollapsedChange. If both are supplied, collapsed wins.

const [collapsed, setCollapsed] = useState(false);

<FilterList
  objectSet={client(Employee)}
  title="Filters"
  collapsed={collapsed}
  onCollapsedChange={setCollapsed}
  filterDefinitions={[
    { type: "PROPERTY", key: "department", filterComponent: "LISTOGRAM" },
  ]}
/>;

onCollapsedChange is only an event listener — it never enables the control and never takes over the state. Availability is governed by enableCollapse alone.

Pass enableCollapse={false} to pin the panel open and remove the control entirely; collapsed and defaultCollapsed are then ignored.

Drag-and-Drop Sorting

Enable reordering of filters via drag and drop:

<FilterList
  objectSet={client(Employee)}
  filterDefinitions={filterDefinitions}
  enableSorting={true}
/>;

Exclude Toggle

LISTOGRAM and TEXT_TAGS filters support an exclude/include toggle. Hover a filter item and click the three-dot menu to toggle between "Keeping" and "Excluding" modes. When excluding, selected values are excluded from results and appear with a strikethrough.

// Exclude mode is built into LISTOGRAM filters automatically.
// Users access it via the overflow menu (three dots) on each filter item.
<FilterList
  objectSet={client(Employee)}
  filterDefinitions={[
    {
      type: "PROPERTY",
      key: "department",
      filterComponent: "LISTOGRAM",
    },
  ]}
/>;

Styling

FilterList uses CSS custom properties included in @osdk/react-components/styles.css for theming. Override --osdk-* tokens to customize FilterList without affecting other components, or override --bp-* tokens for global theming.

@layer osdk.styles, user.theme;

@import "@osdk/react-components/styles.css" layer(osdk.styles);

@layer user.theme {
  :root {
    --osdk-intent-primary-rest: #2563eb;
    --osdk-intent-primary-hover: #1d4ed8;
  }
}

Use the className prop for scoped styling:

<FilterList
  objectSet={client(Employee)}
  className="my-custom-filters"
  filterDefinitions={[...]}
/>

For a full reference of CSS tokens, see the CSS Variables documentation.

Best Practices

  • Memoize filterDefinitions -- define the array outside the component or wrap in useMemo to avoid unnecessary re-renders
  • Persist filter state with defaultFilterStates -- read changes out via onFilterStateChanged, key them with the exported getFilterKey(definition), and pass them back through defaultFilterStates to rehydrate after navigation. serializeFilterStates / deserializeFilterStates handle the Date round-trip for you
  • Use objectSet constraints to scope filter values -- pass a prefiltered objectSet (e.g. client(Employee).where(...)) so filter dropdowns only show relevant values
  • Keep filter lists focused -- show 3-8 filters; too many filters overwhelm users
  • Use addFilterMode="uncontrolled" for progressive disclosure -- start with a few visible filters and let users add more as needed

On this page