Adding dynamically generated URLs to the app
We now want to complete our main layout with a navigation bar, a home page link, as well as a drop-down menu for the countries. To achieve that, we introduce the NavbarSimple
component from Dash Bootstrap Components and see how we can use it.
The NavbarSimple
component will take a few elements to create the structure we want as follows:
- We first create the navigation bar and give it
brand
andbrand_href
arguments, to indicate what the name would be and where it would link to:import dash_bootstrap_components as dbc dbc.NavbarSimple([ … ], brand="Home", brand_href="/")
- For its
children
argument, we will add adbc.DropdownMenu
component. We will also give it alabel
value so users know what to expect when they click on the menu. We will fill itschildren
argument in the next step:dbc.DropdownMenu(children=[ menu_item_1, menu_item_2...