ui.nav_menu
Create a menu of nav items.
Parameters
title : TagChild
-
A title to display. Can be a character string or UI elements (i.e., tags).
*args :
NavPanel
| str = ()-
A collection of nav items (e.g., nav_panel) and/or strings. Strings will be rendered as a section header unless the string is a set of two or more hyphens (e.g.,
---
), in which case it will be rendered as a divider. value : Optional[str] = None
-
The value of the item. Use this value to determine whether the item is active (when an
id
is provided to the nav container) or to programmatically select the item (e.g., update_navs). You can also provide the value to theselected
argument of the navigation container (e.g., navset_tab). icon : TagChild = None
-
An icon to appear inline with the button/link.
align : Literal[‘left’, ‘right’] = 'left'
-
Horizontal alignment of the dropdown menu relative to dropdown toggle.
Returns
:
NavMenu
-
A UI element representing both the navigation menu.
See Also
Example
See nav_panel
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import App, render, ui
app_ui = ui.page_fluid(
ui.navset_card_pill(
ui.nav_menu(
"Nav Menu items",
ui.nav_panel("A", "Panel A content"),
ui.nav_panel("B", "Panel B content"),
ui.nav_panel("C", "Panel C content"),
),
id="selected_card_pill",
),
ui.h5("Selected:"),
ui.output_code("selected"),
)
def server(input, output, session):
@render.code
def selected():
return input.selected_card_pill()
app = App(app_ui, server)