Filter Controls

Beta2.3.0

Filter controls for the filter panel, covering options, hierarchies, dates, numeric ranges, and free text.

import {CheckboxGroupFilter} from "@qualcomm-ui/react/filters"

Overview

Each filter is a control built on one of our existing components. Render it inside a FilterPanel.Filter of a Filter Panel, or inside a FilterProvider under a FilterSetProvider to use it without a panel.

  • CheckboxGroupFilter: string[]. Pick any number of options.
  • CheckboxTreeFilter: string[]. Pick leaves from a hierarchy. Only leaf values are stored.
  • ComboboxFilter: string[]. Search and pick from a long option list.
  • DateFilter: {preset: string} | {range: [string | null, string | null]}. Pick a date range or a preset. Dates are ISO 8601 strings, and null leaves a side open.
  • RadioGroupFilter: string[]. Pick one option. The value is a one-item array.
  • SelectFilter: string[]. Pick from a short option list in a dropdown.
  • SliderFilter: [number | null, number | null]. Pick a numeric range. null leaves a side open.
  • TextInputFilter: string. Enter free text.

List and tree filters render the items of the filter's collection, which comes from its definition or the panel's getFilterCollection. A filter without a collection shows no options. See Loading Options.

Each section below documents only the props specific to that filter. The rest are forwarded to the underlying component.

Checkbox Group Filter

Shows every option as a checkbox. Use it when the list is short enough to scan.

{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.status}>
    <CheckboxGroupFilter />
  </FilterPanel.Filter>
</FilterPanel.Root>

The checkbox group filter has no props of its own. Remaining props are forwarded to the group's <div> element.

Checkbox Tree Filter

Selects leaves from a hierarchy. Checking a branch checks all of its leaves, and only leaf values are stored. The nodes come from the filter's TreeCollection, set on treeFilter.

Snapdragon X
X1E-84-100
X1E-80-100
X1P-64-100
{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.chipset}>
    <CheckboxTreeFilter defaultExpandedValue={["snapdragon-x"]} />
  </FilterPanel.Filter>
</FilterPanel.Root>

The checkbox tree filter has no props of its own. Remaining props are forwarded to Tree.

Combobox Filter

Use a combobox when the list is too long to scan. Typing narrows the options by label.

{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.owner}>
    <ComboboxFilter />
  </FilterPanel.Filter>
</FilterPanel.Root>

The combobox filter has no props of its own. Remaining props are forwarded to Combobox.

Date Filter

Selects a date range, or one of the definition's presets. Ranges are stored as ISO 8601 dates.

{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.submitted}>
    <DateFilter />
  </FilterPanel.Filter>
</FilterPanel.Root>

Presets are listed on the definition. A preset whose value is one of the date picker's presets, like "last7Days", doesn't need a range. Any other preset supplies its own.

dateFilter({
  label: "Submitted",
  presets: [
    {label: "Last 7 days", value: "last7Days"},
    {
      label: "Since release",
      range: () => ["2026-09-01", null],
      value: "release",
    },
  ],
})

A selected preset is stored as {preset: "last7Days"}, not as dates, so it stays relative to the current day. Use resolveDateFilterPreset to turn it into a range when you need one:

import {resolveDateFilterPreset} from "@qualcomm-ui/core/filters"

const [start, end] = resolveDateFilterPreset(preset)

Week presets depend on the locale, and every preset depends on the time zone. Both default to the user's, and can be passed as options.

A date range picker, optionally preceded by a radio group of the definition's presets. Writes {range: [start, end]} with ISO 8601 dates, or {preset}. Resolve a preset to dates with resolveDateFilterPreset.
PropTypeDefault
Label of the option that clears the filter. Only rendered with presets.
string
"Any time"
Whether a custom range can be picked alongside the definition's presets. Without presets, the filter is always a custom range.
boolean
true
Label of the custom range option. Only rendered with presets.
string
"Custom range"
Type
string
Description
Label of the option that clears the filter. Only rendered with presets.
Type
boolean
Description
Whether a custom range can be picked alongside the definition's presets. Without presets, the filter is always a custom range.
Type
string
Description
Label of the custom range option. Only rendered with presets.

Remaining props are forwarded to DatePicker.

Radio Group Filter

Shows every option as a radio, for a single choice. anyLabel adds a leading radio that clears the filter.

{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.architecture}>
    <RadioGroupFilter anyLabel="Any" />
  </FilterPanel.Filter>
</FilterPanel.Root>
A radio group, one radio per item of the filter's list collection. Selects one item. Writes a one-item string[]. Renders nothing while the filter has no collection.
PropType
The label of a leading radio that clears the filter, such as "Any". Omit to render only the collection's items.
string
Type
string
Description
The label of a leading radio that clears the filter, such as "Any". Omit to render only the collection's items.

Remaining props are forwarded to RadioGroup.

Select Filter

Use a select for a short list where a dropdown saves space. For longer lists, use the Combobox Filter.

{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.standard}>
    <SelectFilter />
  </FilterPanel.Filter>
</FilterPanel.Root>

The select filter has no props of its own. Remaining props are forwarded to Select.

Slider Filter

Selects a numeric range with a two-thumb slider. A thumb left at its bound is stored as null, which leaves that side open. The value is written when a thumb is released.

The bounds come from the definition's min and max. Use formatValue on the definition to format the values in summaries.

0 - 120
{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.duration}>
    <SliderFilter />
  </FilterPanel.Filter>
</FilterPanel.Root>

The slider filter has no props of its own. Remaining props are forwarded to Slider.

Text Input Filter

Captures free text. In auto mode, the value is committed once the user stops typing.

{}
<FilterPanel.Root
  className="w-72"
  filters={filters}
  onValueChange={setValue}
>
  <FilterPanel.Filter filter={filters.buildPath}>
    <TextInputFilter />
  </FilterPanel.Filter>
</FilterPanel.Root>
A text input that captures free text. Writes a string.
PropTypeDefault
Milliseconds to wait after typing stops before committing in auto apply mode. Manual mode writes the draft on every keystroke.
number
300
Type
number
Description
Milliseconds to wait after typing stops before committing in auto apply mode. Manual mode writes the draft on every keystroke.

Remaining props are forwarded to TextInput.

Updated by Ryan Bower