Similar to menuItem but for the dashboardHeader.
Like sidebarMenu but inside dashboardHeader.
navbarTab(text, ..., tabName = NULL, icon = NULL, .list = NULL)
navbarMenu(..., id = NULL)
updateNavbarTabs(
session = shiny::getDefaultReactiveDomain(),
inputId,
selected = NULL
)
Tab text.
Slot for navbarTab.
Should correspond exactly to the tabName given in tabItem.
An icon tag, created by shiny::icon. If NULL, don't display an icon.
Use this slot if you had to programmatically pass navbarTab like with lapply.
Menu id. Useful to leverage updateNavbarTabs on the server.
Shiny session object.
The id of the tabsetPanel
, navlistPanel
,
or navbarPage
object.
If TRUE
, this menuSubItem
will start selected. If no item have selected=TRUE
.
You can nest navbarTab so it does like menuSubItem. This is to avoid to create too many functions.
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
)
}
)
}