This updates the hidden body tabset used by tabItems() and keeps the
sidebar active item synchronized with the selected tab.
Usage
updateTabItems(
session = shiny::getDefaultReactiveDomain(),
inputId,
selected = NULL
)Examples
if (interactive()) {
shiny::shinyApp(
ui = dashboardPage(
header = dashboardHeader(title = "Demo"),
sidebar = dashboardSidebar(
sidebarMenu(
id = "sidebarMenu",
menuItem("Overview", tabName = "overview"),
menuItem("Reports", tabName = "reports")
)
),
body = dashboardBody(
shiny::actionButton("go_reports", "Go to reports"),
tabItems(
tabItem(tabName = "overview", shiny::h2("Overview")),
tabItem(tabName = "reports", shiny::h2("Reports"))
)
)
),
server = function(input, output, session) {
shiny::observeEvent(input$go_reports, {
updateTabItems(session, inputId = "sidebarMenu", selected = "reports")
})
}
)
}
