...
/Allowing Users to Add Dynamic Components to the App
Allowing Users to Add Dynamic Components to the App
Get familiar with adding dynamic components to a Dash application.
We'll cover the following...
Let’s take things to an even more abstract and powerful level. Let’s now allow users to add full components by clicking a button.
Not only will users be able to add components to the app’s layout, but the components’ contents will also be dynamically generated. Take a look at the illustration below for the simplest example that we will start with:
Although extremely simple, the charts in this app have different dynamic names, as we can see in the chart titles. This was based on the dynamic value of n_clicks
, which changes with every click.
The amount of code required to generate this is similar to any simple app—there isn’t much complexity involved. We just need to look at it with fresh eyes.
Creating the layout of the app
Let’s start by coding the layout, which will consist of two simple components.
- We create a button to trigger the addition of new charts.
dbc.Button(&quo