from functools import partialfrom shiny.express import uifrom shiny.ui import page_navbarui.page_opts( title="App with navbar", page_fn=partial(page_navbar, id="page"), )with ui.nav_panel("A"): "Page A content"with ui.nav_panel("B"): "Page B content"with ui.nav_panel("C"): "Page C content"
from shiny import App, uiapp_ui = ui.page_navbar( ui.nav_panel("A", "Page A content"), ui.nav_panel("B", "Page B content"), ui.nav_panel("C", "Page C content"), title="App with navbar", id="page", ) def server(input, output, session):passapp = App(app_ui, server)
Follow these steps to add a navbar to the top of your app:
Define a navbar page layout with ui.page_navbar().
Pass nav items (e.g., ui.nav_panel() and ui.nav_menu()) to ui.page_navbar() to control the items displayed in the navbar.
Set the title argument of ui.page_navbar() to set the browser window title.
Optional: Pass a string to the id argument of ui.page_navbar(). This will create an input value that holds the title of the currently selected nav item. For example, id = "tab" would create a reactive value accessible as input.tab().
from functools import partialfrom shiny.express import uifrom shiny.ui import page_navbarui.page_opts( title="App with navbar", page_fn=partial(page_navbar, id="page", position="fixed-bottom"), )with ui.nav_panel("A"): "Page A content"with ui.nav_panel("B"): "Page B content"with ui.nav_panel("C"): "Page C content"
from shiny import App, uiapp_ui = ui.page_navbar( ui.nav_panel("A", "Page A content"), ui.nav_panel("B", "Page B content"), ui.nav_panel("C", "Page C content"), title="App with navbar", id="page", position="fixed-bottom", ) def server(input, output, session):passapp = App(app_ui, server)
Follow these steps to add a navbar to the bottom of your app:
Define a navbar page layout with ui.page_navbar().
Pass nav items (e.g., ui.nav_panel() and ui.nav_menu()) to ui.page_navbar() to control the items displayed in the navbar.
Set the position parameter of ui.page_navbar() to "fixed-bottom" to pin the navbar to the bottom of the app. By default, position is "static-top", which causes the navbar to display at the top with normal scrolling behavior. You can also pin the navbar to the top (position="fixed-top").
Set the title argument of ui.page_navbar() to set the browser window title.
Optional: Pass a string to the id argument of ui.page_navbar(). This will create an input value that holds the title of the currently selected nav item. For example, id = "tab" would create a reactive value accessible as input.tab().