I’m trying to implement a simple NavBar that has the login/logout button - if user is not logged in - for the login button to appear - but once the user is logged it - for the bar to display the logout button
How can I get the layout adjusted dynamically?
#APP LAYOUT
app.layout = html.Div([
dcc.Location(id='url', refresh=False),
navbar_with_login,
html.Div(id='page-content'),
])
#MAIN ROUTING
@app.callback(
Output('page-content', 'children'),
Input('url', 'pathname')
)
def display_page(pathname):
if pathname == '/':
return layout_front_page
if pathname == '/login':
return login
#NAVBAR
navbar = dbc.NavbarSimple(
children=[
dbc.NavItem(dbc.NavLink("Login", href="/login")),
#How to dynamically display login vs logout here>
nav=True,
in_navbar=True,
label="More",
),
],
brand="NavbarSimple",
brand_href="#",
color="primary",
dark=True,
)