Sub topic 8
Choosing Filter Controls for Your Data
Assume you know basic forms, lists, and common web controls. This chapter focuses on choosing controls for filtering, not on designing search fields or ranking results.
A filter narrows a collection by a known property. The right control reflects the data type, the number of possible values, and whether people can choose one value or several. Do not choose a control only because it is familiar. A control that hides important choices or allows invalid combinations makes the result harder to trust.
Match the control to the data
Start by asking three questions:
- What kind of value is being filtered?
- How many values are available?
- Can the user select one value, several values, or a continuous range?
| Data shape | Suitable control | Main consideration |
|---|---|---|
| Two states | Checkbox or switch | Make the meaning of the checked state explicit |
| One value from a short list | Radio buttons or select | Show all options when comparison matters |
| Several values from a short list | Checkboxes | State whether choices mean “any” or “all” |
| Many categorical values | Searchable list or facet | Help users find values without a long menu |
| Numeric or date interval | Range inputs or min/max fields | Show units and validate the bounds |
| Ordered values with useful steps | Slider | Provide exact values and an accessible alternative |
A checkbox works well for an optional condition such as “In stock.” A switch is better for changing a setting that takes effect immediately. Do not use a switch merely because it looks compact.
For mutually exclusive choices, use radio buttons when the options are few and visible. Use a select control when space is limited or the list is longer. For independent choices, use checkboxes. Label the group so users understand whether selecting “Boots” and “Sandals” shows items matching either category or both categories.
Consider cardinality and effort
Cardinality means the number of possible values. A list of four brands can display four checkboxes. A list of 400 brands needs a searchable facet, alphabetical grouping, or a staged view such as “Show more.”
Frequent filters deserve prominent placement. Rare or advanced filters can be inside a filter panel. Avoid making users open several panels just to compare common choices.
For numeric data, decide whether people think in exact values or approximate ranges. Price often needs minimum and maximum fields because users may know a budget boundary. A slider can support quick exploration, but a slider alone makes precise entry difficult.
type FilterControl =
| { kind: "checkbox"; label: string; value: boolean }
| { kind: "multi-select"; label: string; values: string[] }
| { kind: "range"; label: string; min?: number; max?: number };
const controls: FilterControl[] = [
{ kind: "checkbox", label: "In stock", value: true },
{ kind: "multi-select", label: "Brand", values: ["Northwind"] },
{ kind: "range", label: "Price", min: 50, max: 150 },
];Make behavior predictable
Use plain labels such as “Price” and “Brand.” Explain unusual behavior near the control. If several values within one facet are combined with OR, say “Any brand.” If separate facets combine with AND, a user choosing a brand and a price range should understand that both conditions apply.
Preserve selected values when another filter changes. Show the active choices near the results, and provide a clear way to remove one choice without resetting everything.
A practical decision path
Test the control with realistic data, including long labels, no available values, and conflicting selections. A good filter reduces effort while keeping the available choices and the resulting behavior understandable.
Exercise
You need to filter 300 products by brand. Users may select several brands, and most users choose from a small set of popular brands. Which control would you choose?
Show answer
Use a searchable multi-select facet. Show popular brands first, allow several selections, and provide a way to search the full list.