Change the selected tab on the client
Usage
update_tab_items(session = shiny::getDefaultReactiveDomain(), tab)
updateTabItems(session = shiny::getDefaultReactiveDomain(), tab)
Arguments
- session
The session object passed to function given to shinyServer
- tab
The name of the tab that should be selected
Functions
updateTabItems()
: Change the selected item on the client (alias forupdate_tab_items
for compatibility withshinydashboard
)
Examples
if (interactive()) {
ui <- dashboardPage(
dashboardSidebar(
sidebarMenu(
menuItem("Tab 1", tabName = "tab1"),
menuItem("Tab 2", tabName = "tab2")
)
),
dashboardBody(
tabItems(
tabItem(tabName = "tab1", h2("Tab 1")),
tabItem(tabName = "tab2", h2("Tab 2"))
)
)
)
server <- function(input, output, session) {
update_tab_items(tab = "tab2")
}
shinyApp(ui, server)
}