Allowing users to add dynamic components to the app
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 Figure 10.6 for the simplest example that we will start with:
Although extremely simple, the charts in this app have different dynamic names, as you can see in the chart titles. This was based on the dynamic value of n_clicks
, which changes on 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. Let's start by coding the layout, which will consist of two simple components:
- Create a button to trigger the addition of new charts:
dbc.Button("Add Chart", id='button')
- Create an empty div, with its
children
attribute...