Hello,
I would like to generate the list of dbc.NavLink under dbc.Nav through looping over a dictionary.
How could I generate the following:
dbc.Nav(
[
dbc.NavLink("GitHub", href=f"https://github.com", active="exact"),
dbc.NavLink("Plotly", href=f"https://dash.plotly.com/", active="exact"),
dbc.NavLink("Pandas", href=f"https://pandas.pydata.org/", active="exact"),
],
via looping through the following dictionary:
navlinks_dict = {'names' : ['GitHub', 'Plotly', 'Pandas'],
'urls' : ['https://github.com', 'https://dash.plotly.com/', 'https://pandas.pydata.org/'],
'active_status' : ['exact', 'exact', 'exact']}
I have tried the following, which does not work as I don’t know how to refer to each field within dbc.NavLink:
navlink_list = []
for i in range(len(navlinks_dict['names'])):
navlink_list.append(dbc.NavLink(navlinks_dict['names'][i], href = navlinks_dict['urls'][i], active = navlinks_dict['active_status'][i]))
Apologies for the code formatting, I can’t seem to fix it on my post.
Thank you very much.