Showing data on your pages

How to design loading, empty and error states

How to design loading, empty and error states

In TeleportHQ, a list bound to data has extra versions for the moments when there are no items to show: while data is loading, when the list is empty (for example, a search found nothing), and for CMS lists and items when loading fails (error). To design one, select the list, turn on Override State in its UI State row, pick the state, and edit what it shows on the canvas. Visitors see each version automatically when that moment happens.

Before you start

Which states each TeleportHQ element has

ElementNormal viewOther states in the UI State listBranches in the layers tree
Array Mapperlist (the items)empty, loadingItems, Empty, Loading
CMS listthe itemsempty, loading, errorSuccess, Error, Loading
CMS itemthe entryloading, errorSuccess, Error, Loading

Steps

  1. Select the list: on the canvas or in the layers tree, click it, for example Products List. The right panel shows Array Mapper Settings (or Collection Settings for a CMS list).
  2. Find the UI State row.
  3. Turn on Override State. The list below it becomes active, set to list (loading on a CMS list or CMS item).
  4. In the list, choose the state, for example empty. The canvas now shows that state's content.

    The TeleportHQ UI State row with Override State turned on and the empty state chosen
  5. Edit the content on the canvas. For example, change the text to "No cakes match your search" and add a button that clears the search.
  6. Style it like any other element.
  7. Turn Override State off to go back to the real data.

Each state is also a branch of the list in the layers tree (Items, Empty and Loading for an Array Mapper), so you can select and edit its elements there.

The branches of a TeleportHQ list in the layers tree: Items, Empty and Loading

Check that it worked

With Override State on, the canvas shows your design for the chosen state. On your published site, visitors see it on their own: the loading version while data loads (also while a filter, sort or search change loads new items, but not while infinite scroll or Load more adds items below the ones shown), the empty version when nothing matches, and for CMS elements the error version when the CMS can't be reached.

Troubleshooting

My list is empty on the canvas Override State may still be on with empty or loading chosen. Turn it off.

Override State made no change on my live site That's expected. Its info icon says: "This toggle does not have any impact on production code, it is for previewing and building purposes only." It only changes what you see while designing, and it isn't saved with the project.

There's no UI State row The project is read-only for you, or the selected element isn't a list. Select the Array Mapper itself, not an item inside it.

Good to know

  • Examples of good empty states: "No events scheduled yet", or "No products match your filters" with a link that clears the filters.
  • Loading states are best kept light, for example grey boxes the size of your cards, or a short "Loading…" text.
  • Mixed Type elements have a Default and an Error mapping instead of UI states. See How to use CMS List, CMS Item, Rich Text and Mixed Type.
  • For a single empty field inside a card, show a fallback value instead. See How to show a fallback when data is missing.
Share

Related Articles

How to show a list of items (List / Array Mapper)

In TeleportHQ, you show a list of items, such as products from a database, by adding an Array Mapper from Elements → List, binding its Source to a data source table in Array Mapper Settings, and designing one card inside it that repeats for every item.

How to use CMS List, CMS Item, Rich Text and Mixed Type

When a headless CMS is connected to your TeleportHQ project, the Elements panel shows a CMS group with CMS list (many entries), CMS item (one entry), Rich Text (formatted content) and Mixed Type (a different component per entry type), which you bind to your CMS content types in the right panel.

How to add search to a list

In TeleportHQ, you add a search box to a list by selecting an Array Mapper or Table bound to a data source and ticking Enable search; TeleportHQ adds a search input that filters the list by its text fields, in Preview and on your published site.

How to filter a list

In TeleportHQ, you filter a list by selecting an Array Mapper or CMS list bound to data, clicking + next to Filtering in the right panel, choosing a field, an operand and a value in Filtering Options and clicking Save Changes; several filters must all match, and on database lists you can switch them to OR and group them.

How to show a fallback when data is missing

In TeleportHQ, when you bind a field to a data source or to a list item, a "fallback value" box appears under the binding in the right panel; type the text to show when the data is empty or missing, such as "No description yet", and press Enter.