How to filter a list
In TeleportHQ, you filter a list so it shows only matching items, for example only cakes, or only products under 20. Select the list (an Array Mapper or a CMS list), click + next to Filtering in the right panel, choose a field, an operand such as = or < and a value, then click Save Changes. When a list has several filters, all of them must match; on lists from a database you can switch them to OR and put them in groups.
Before you start
- The list must be bound to a data source or a headless CMS. See How to show a list of items.
- Filtering only lists fields that hold text, numbers or true/false values.
Add a filter
- Select the list: in the layers tree, click its row, for example Products List. The right panel shows Array Mapper Settings.
Scroll to Filtering and click the + at its right. The Filtering Options panel opens beside the right panel.
- In Select attribute, choose the field to filter on, for example
category. - Next to Operand:, choose how to compare, for example
=. The operands are listed below. - In Value, type the value, for example
cakes. - Click Save Changes.
The filter shows under Filtering as a line like category = cakes, and the canvas shows only matching items.
- Select attribute: the field the filter checks.
- Operand: how to compare.
- Value: what to compare with.
- Save Changes: adds the filter.
Operands
| Operand | Shows items whose field… |
|---|---|
= / ≠ | equals / doesn't equal the value |
> < >= <= | is greater or smaller than the value |
is null / is not null | is empty / has a value. No value to type. |
has any | is a list (for example a product's categories) that shares at least one value with yours |
is any of | equals any of several values, typed with commas, for example cakes, bread |
A true/false field only offers =. Point at the info icon to read "The selected attribute only supports the = operation."
Combine filters with AND or OR
When a TeleportHQ list has several filters, an AND label sits between them: an item must match all of them. On a list from a database (the TeleportHQ database, Supabase, PostgreSQL, MySQL and the other databases), you can change that:
- Click the AND label between two filters. It changes to OR: an item that matches any of the filters shows. Click it again to go back to AND.
- To mix both, tick the box in front of two or more filters, then click Group selected (2). The filters move into a box marked Group, which uses the opposite word, for example OR inside an AND list. So "price < 20 AND (category = cakes OR category = bread)" is one filter plus a group of two.
- To break a group apart, click Ungroup in its header. To delete a filter or a whole group, click the × at its right.
Lists from a REST API, a Google Sheet, a CSV file or a headless CMS show their filters as a simple list: every filter must match.
Let visitors change the filter
The value of a TeleportHQ filter can come from something visitors change. In Filtering Options, click the plug icon next to Value and pick:
- a state, for example
selectedCategory, that buttons or a dropdown change. See How to store and use values with States. - a URL Param, so
/products?category=cakesshows cakes. The page must declare the parameter first: on the page, click Page settings above the canvas, open the SEO tab and add it under Page Params. Page Params are available in web apps. - a prop (a component setting), when the list is inside a component.
When the bound value is empty, TeleportHQ skips that filter, so an "All" button can set the state to an empty text to show every item.
Check that it worked
The canvas shows only the items that match. Click Preview in the bottom toolbar to try filters that visitors change, then publish and check your live site.
Troubleshooting
The field I want isn't in Select attribute Only text, number and true/false fields appear. If you added the field recently, refresh the data source. See How to refresh, edit or remove a data source.
There's no + next to Filtering The list isn't bound to a data source, or its source has no field that can be filtered. On a CMS list, "Pagination, filtering and sorting are disabled for single types".
I can't group filters or switch to OR Groups and OR are only offered for lists from a database. Lists from a REST API, a Google Sheet, a CSV file or a CMS always need every filter to match.
A filter works in the editor but not on my live site First publish again: filter changes only reach the live site when you publish. If it still differs, check these known differences:
- On a list with Paginated or Enable search turned on, the published site doesn't apply
is nullandis not nullfilters the way the editor does. On other lists they work on the live site too. has anyis only reliable on lists from the TeleportHQ database or PostgreSQL, andis any ofdoesn't work on lists from Supabase, a REST API, a Google Sheet, a CSV file or JavaScript.
Contact support at hello@teleporthq.io with the page link if one of these affects you.
Good to know
- Filters, sorting, search and pagination work together: visitors search within the filtered list, in your chosen order, page by page.
- On a headless CMS from WordPress, a filter has no operand: the value box reads Equals To.