My dash application has navigation based on recipes found in the available dash documentation. It works, but it does not look nice. Who knows a better way to introduce menus? I don't want to develop a special meteor component, but I will be glad to use one of the presently available frameworks (bootstrap,semantics,...).
import dash,copy
from dash.dependencies import Input, Output, State
import dash_core_components as dcc
import dash_html_components as html
app = dash.Dash(__name__)
server = app.server
nav_menu = html.Div([
dcc.Link(' [Page A] ', href='/page-a'),
dcc.Link(' [Page B] ', href='/page-b'),
])
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
nav_menu,
html.Div( [html.Div( [html.H6('A')], id = 'page-a' ),
html.Div( [html.H6('B')], id = 'page-b' )],
style = {'display': 'block'})
])
@app.callback(
Output(component_id='page-a', component_property='style'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/page-a':
return {'display': 'block'}
else:
return {'display': 'none'}
@app.callback(
Output(component_id='page-b', component_property='style'),
[Input('url', 'pathname')])
def display_page(pathname):
if pathname == '/page-b':
return {'display': 'block'}
else:
return {'display': 'none'}
app.css.append_css({"external_url": [
"https://codepen.io/chriddyp/pen/bWLwgP.css",
"https://codepen.io/chriddyp/pen/rzyyWo.css"
]})
if __name__ == '__main__':
app.run_server(debug=True)