How to use Repeating Groups in Bubble

Repeating Groups are among the most used and useful element types in Bubble.io. Just like other Bubble group types, they are containers that can hold other elements in a parent/child relationship, but the Repeating Group is different than the other group types in specific ways. Let’s look at how it’s different, and when you should use it.

What is a Repeating Group?

The easiest way to explain it is to look at its name: as it suggests, whatever you put into a Repeating Group will be repeated. What does that mean exactly? Before we dig into it, let’s talk a little bit about lists in Bubble, because they make up the foundation for Repeating Groups.

Everything that you load into Bubble (such as database records from a search, Option Sets, text/numbers or the results of an API call) is either a single item or a list. For example, let’s say you use the Do a Search for to search for all the Users registered in your app. Bubble will not only provide you with one User, but a list of all users it can find – a list. If you have a background in programming, you’ll be more familiar with the term array. It’s useful to note that even if there’s only one record return (if you only have one registered User in your database for example), the result will still be a list with only one record.

Single records on the other hand, point to one specific record (such as a particular user or a single Option in an Option Set).

Lists and single records behave a bit differently in Bubble. In a regular Group, you can only ever load a single record. In a Repeating Group however, you can’t load one record on its own: you need to provide a list of records.

Regular groups contain the data for its specified record, but a Repeating Group repeats its content once for every record in a list. This is how you make any kind of visual list in your application. Imagine your Gmail inbox for example: your emails are neatly displayed in rows. In Bubble, each of those rows would be one cell of a repeating group, and the mails in your inbox would be your list.

A Gmail inbox illustrating the use of Repeating Groups to show lists of data.
Repeating Groups can be used to display a list of Things as a list of rows, just like your Gmail inbox. Each row is called a cell.

Repeating Groups are not restricted to just listing in a row though: just like any other element, you decide how to design the final presentation for your users. In the example below, we’ve told Bubble to not only use rows, but columns too, to create a kind of card design to show off the products of a Dubai-based tour operator:

Using Repeating Groups in Bubble to display a list as cards.
On the Bubble-made website www.oceanairtravels.com, these four cards make up four cells in a Repeating Group. Each cell fetches data from its corresponding record in the list.

How to set up Repeating Groups

Just like a regular Group, a Repeating Group is a container in which you can place any kind of element. For each cell (rows and/or columns) of data you fetch, Bubble will repeat the elements that you set up in the initial group. Take a look at the card design in the image above this header, and you’ll notice their design looks exactly the same. Instead of setting up 4 different groups with identical design, we simply set up one Repeating Group which then duplicates that design for each record. In this illustration, we’re looking a Products saved in the database that each have a unique header, price, description, etc.

Let’s use Products as a basis for building our first Repeating Group.

Creating the data and element

The first thing we’re going to do is to create our Product Data Type. We’re going to keep things really simple for now. Go to the Data Tab and create a new Type called Product, and add the two fields Name and Price.

Adding fields to a Data Type in Bubble

Next, let’s add a few Products to the database simply for testing purposes. We don’t need to set up a form for this as of now, we’ll just add it directly to the database using Bubble’s own database editor:

Manually adding entries to the Bubble database
Using Bubble’s own database editor, we can quickly add some test Products to our app. Add both the name and the price to a few Products.

Great! So now we have a database containing four Product records. Now it’s time to see how we can make these records visible in our app, so that our customers can browse these four exciting products of ours. Go to the Design tab and pick the Repeating Group from the left-hand element tree. Then draw a group on the page looking something like the one below:

Bubble will add four rows to your list by default.

Loading the data

Next, we’ll need to tell Bubble what to show. We’ll do this in two steps:

  • Pick the type of data we want to show
  • Set the source of the data (i.e. where we want Bubble to find it)

Double-click the Repeating Group that you created to bring up the Element Property Editor. Follow the steps below:

  1. First, we set the Type of content to Product. This tells Bubble that the type of data we want to load is the newly created Product data type
  2. Next, we set the Data Source. In this field we’ll use the Do a Search for function to search our database for available Products
  3. This will bring up the window to the right, where you again set the Type to Product. You don’t need to add any constraints, as we want Bubble to find all Products.
Searching for data in the database to show it in a Repeating Group

Privacy rules and Repeating Groups

Whenever you display data in your app, it’s imperative to use Privacy Rules to keep data secure and private. We won’t go into detail on how that works in this article, but we have a full article on How to Set up Privacy Rules in Bubble that you should check out if you’re unfamiliar with it. It’s one of those things that’s less fun than designing, but believe me, it’s worth learning.

Designing the Repeating Group

Let’s first look at one of the most basic principles of designing Repeating Groups: you only design one cell, and the content is automatically duplicated to all other cells. What you’ll notice as you start clicking your way around the element, is that you can’t actually add anything to the bottom 3 rows – only the first one is editable.

Showing the editable cell of Repeating Groups in Bubble

As I add two text elements to the first cell, you’ll see that these are represented in the following cells with a faded color. This fading is only there in the editor – in your app each row will seem identical.

Showing faded elements illustrating which Repeating Group cell is editable
Bubble shows the non-editable rows with a faded color.

Now, let’s change the text into something more interesting. We have two fields on our Product data type that we can show: Name and Price. So let’s display the name on the left and the price on the right. Note that I’ve right-aligned the rightmost text.

Select the left text element in the first cell and set the following expression:

Setting up a text to show the Product name
Choosing the Current Cell’s Product will let us display data relevant to the Product in that specific cell (row)

Repeat the same step for the rightmost text element, choosing Price this time. Now click the Preview button in Bubble, and you’ll be looking at the following:

A Repeating Group with borders showing a list of Products in Bubble.io

Now, as you, see, we already have a pretty decent looking product list with both Name and Price, and all it took was a few minutes. Nice work you!

How Bubble loads Repeating Groups

Bubble will intelligently not load more data than it needs, to keep the loading time snappy. Depending on your RG’s settings (which we’ll go through below), you can keep Bubble loading just a few elements, even if the database contains thousands or millions of them.

It’s best practice to never load and/or display more data than you need, as it will quickly start to slow everything down. You’ll note in other apps that you use that they rarely load hundreds of records of anything – they’ll usually either set things up with pagination (where one page displays a set number of results such as 25, like Gmail) or continued loading, where the content is loaded as you scroll (like Instagram or Facebook).

This is not simply a design decision, but a key compromise in keeping the app loading and running smoothly. It’s by no means a Bubble-specific thing: all web apps face the same challenge. Another common solution to keep loading times down is to hide information until a User actually asks for it: maybe you don’t need to load that full Repeating Group on page load?

How Repeating Group design affects performance

A common mistake when setting up Repeating Groups is to overlook how the design of the RG can impact your app’s performance. Keep in mind that everything you place inside the cell of a Repeating Group will be multiplied for as many rows and columns that you’re showing. If you place a high number of elements, nested searches and Conditions within a Repeating Group cell, you may not notice any difference during testing, but once you get users into your app and the data starts growing, your app will gradually slow down.

Animation of a sloth slowly stamping paper.
Bubble rendering long Repeating Groups with lots of elements, nested searches and conditions.

You can read more about how the number of elements affect performance in our article on top things to do for Bubble performance and our book The Ultimate Guide to Bubble Performance.

Repeating Group settings

Now that we’ve set up our beautiful Product list, let’s have a look at the other settings we have at our disposal:

Layout style

Layout styles determine two important things in your list:

  1. how should the Repeating Group behave as your User’s navigate your app
  2. how much data should Bubble initially load when displaying the group for the first time.

These are both important points for your application. The first one affects your app’s UX and determines the way in which Bubble shows the search results. The second one determines the amount of data Bubble loads and displays when the Repeating Group is loaded, and can greatly affect the performance of your app. You’ll find five different styles in the element editor:

Bubble's different Repeating Group Layout Styles
Bubble offers five different styles for Repeating Groups that can greatly affect both the behavior and performance of your app.

Vertical Scrolling

The Vertical Scrolling option will load as many rows as you specify in the Rows tab, and then keep loading more results as the User scrolls the list (Bubble may also load a few more than its showing to keep the scrolling smooth). If you have enough records to need a scrollbar, the bar will be confined within the Repeating Group element, making it an isolated list that the User can scroll independently of the page.

From a performance perspective, this is a good choice, since it limits the number of records Bubble has to download and display on page load.

Extendable Vertical Scrolling

This option too will load the number of rows that you specify and load as the User scrolls. The difference is that this list will scroll along with the page scrolling. The easiest way to illustrate how it works is to think of how an ever-scrolling social media site like Facebook and Instagram work: as you scroll the page, they’ll keep loading new posts.

Just like Vertical Scrolling, this option is performance-friendly.

Full list

Like the name suggests, this option will load all records it can find and display them all at once. This can be great as long as you’re in control of how many that will be, but if your app keeps growing, loading a full list can start slowing your app down both during page load and use. The first reason is that Bubble has to download all the database records at once, instead of spreading it out over time. The second reason is that the number of elements on your page can balloon, which takes time to render for the local device you’re on.

Fixed number of cells

This option will show the number of rows that you specify in the Rows setting, and no more. There’s no scrollbar, and nothing the User can do to load more records than you’ve set to display.

Horizontal scrolling

If you choose Horizontal Scrolling, Bubble will disregard rows at all, and assume that you want to scroll horizontally instead, even hiding the Rows option in the RG settings. Just like Vertical Scrolling, Bubble will treat the RG as an isolated element, adding a scrollbar at the bottom border of the element, and not on the page level. To visualize this Option, think of how Netflix and HBO allow you to scroll rows of movies and TV shows horizontally.

Further reading

You may also be interested in our article on all Bubble Group types. Bubble.io also have a nice introduction to Repeating Groups video on Youtube. If you’re struggling with responsiveness in your RG’s, Buildcamp’s Responsive Repeating Groups video offers some great advice. If you want to learn more about building performant Bubble apps, check out our book The Ultimate Guide to Bubble Performance.

If you have questions, spot a mistake in the article or think it could otherwise be improved, don’t be shy letting us know in the comment section. If you want to contribute keeping these articles free, consider buying me a coffee!

Support the site and keep it free ❤️

I love tech startups and the Bubble community, and have made it my mission to try and create content that’s valuable, easy to follow and entertaining.

Creating content next to full-time consulting work is time-consuming; if you’d like to support it and keep the site free for everyone, please consider buying me a coffee or becoming a supporting member.

Buy Me A Coffee

Share:

More Posts

What is a Data Concept?

The Data Concept is a framework on how to think about the data in your app in order to set up an efficient database structure.

Satellite Data Types in Bubble

In our last Bubble.io article, we looked at how we can use the Data Weight analogy to visualize how the structure of our Data Types can affect performance. But what do we do with the information? What is a Satellite

What is Data Weight?

Data Weight is a way to think about your database structure when you build for performance.

Understanding Bubble Groups

Bubble has five different group types. While they’re all used as containers, their use differs greatly. This article explains the difference between them in detail.

Leave A Reply

Your email address will not be published. Required fields are marked *

*