if (interactive()) {
library(shiny)
library(bs4Dash)
tabs <- tabItems(.list = lapply(1:7, function(i) {
tabItem(tabName = sprintf("Tab%s", i), sprintf("Tab %s", i))
}))
shinyApp(
ui = dashboardPage(
header = dashboardHeader(
navbarMenu(
id = "navmenu",
navbarTab(tabName = "Tab1", text = "Tab 1"),
navbarTab(tabName = "Tab2", text = "Tab 2"),
navbarTab(
text = "Menu",
dropdownHeader("Dropdown header"),
navbarTab(tabName = "Tab3", text = "Tab 3"),
dropdownDivider(),
navbarTab(
text = "Sub menu",
dropdownHeader("Another header"),
navbarTab(tabName = "Tab4", text = "Tab 4"),
dropdownHeader("Yet another header"),
navbarTab(tabName = "Tab5", text = "Tab 5"),
navbarTab(
text = "Sub sub menu",
navbarTab(tabName = "Tab6", text = "Tab 6"),
navbarTab(tabName = "Tab7", text = "Tab 7")
)
)
)
)
),
body = dashboardBody(tabs),
controlbar = dashboardControlbar(
sliderInput(
inputId = "controller",
label = "Update the first tabset",
min = 1,
max = 4,
value = 1
)
),
sidebar = dashboardSidebar(disable = TRUE)
),
server = function(input, output, session) {
observeEvent(input$controller, {
updateNavbarTabs(
session,
inputId = "navmenu",
selected = paste0("Tab", input$controller)
)
},
ignoreInit = TRUE
)
}
)
}
Run the code above in your browser using DataLab