Option sets allow you to have a static list of choices, "Options", which are global to your app. This is great for situations where you know ahead of time what options are possible for a variable - things like days of the week, marital status, team name for a given user, etc. You can create them in the Data tab, add various options to them, and even add attributes to your options. You can use option sets anywhere you would use a normal custom type: as a field on a thing, as a type of a repeating group, etc. They are especially useful for dropdowns, but can have a wide variety of uses all around your application, by both speeding up existing functionality and helping with readability and good practices.
Overview / Tutorial
There is a tab in the Data section titled Option sets. There, you can create, update, and delete option sets, like you would for regular custom types.
Once created, you can add attributes to your options. Attributes are like fields on your custom types; they have a type and a name, and from each option you can access its attributes. There is an attribute common to all option sets: the Display attribute. This gets the name of your option, and is especially useful for displaying options inside of dropdowns.
Next, you can add options to your sets by typing its Display in and clicking “Add option”. Once created, you can click on “modify attributes” to modify any of the additional attributes you created for your options.
There are a couple of ways to actually use options. The first is a new global data source, "Get an option". This allows you, from anywhere in your app, to access any option on one of your option sets. You can also access the special “All options” selection to get a list of all options. Once you have the option you want, you can access its attributes or its display value.
In addition, Bubble is smart about suggesting options. If the field you are filling in requires an option, it will move all of the options to the top of the dropdown; likewise, if the field requires a list of options (like in a dropdown), it will push the “All ” selection to the top.
Comparison vs. Custom types
It's technically possible to get many of the benefits of option sets using normal custom data types. You should consider option sets instead for a few reasons:
- Options are faster to access, as they require no database reads
- Options sets are easily extensible to add new options and change existing ones. Renaming an option will propagate throughout your app.
- Options sets are easier to use. They can be accessed from anywhere in your app, and are a lot easier to access than doing a search.
However, there are a couple of downsides compared to custom types:
- There are no privacy settings for options. So, do not put sensitive data as an option’s display or one of its attributes.
- To add new options or change existing ones, you must push a new version of an app, unlike regular data which you can add while your app is live.