sidebarMenu: Create a dashboard sidebar menu and menu items.

Description Usage Arguments Details See Also

View source: R/dashboardSidebar.R


A dashboardSidebar can contain a sidebarMenu. A sidebarMenu contains menuItems, and they can in turn contain menuSubItems.


sidebarMenu(..., id = NULL, .list = NULL)

menuItem(text, ..., icon = NULL, badgeLabel = NULL, badgeColor = "green",
  tabName = NULL, href = NULL, newtab = TRUE, selected = NULL,
  expandedName = as.character(gsub("[[:space:]]", "", text)),
  startExpanded = FALSE)

menuSubItem(text, tabName = NULL, href = NULL, newtab = TRUE,
  icon = shiny::icon("angle-double-right"), selected = NULL)



For menu items, this may consist of menuSubItems.


For sidebarMenu, if id is present, this id will be used for a Shiny input value, and it will report which tab is selected. For example, if id="tabs", then input$tabs will be the tabName of the currently-selected tab. If you want to be able to bookmark and restore the selected tab, an id is required.


An optional list containing items to put in the menu Same as the ... arguments, but in list format. This can be useful when working with programmatically generated items.


Text to show for the menu item.


An icon tag, created by icon. If NULL, don't display an icon.


A label for an optional badge. Usually a number or a short word like "new".


A color for the badge. Valid colors are listed in validColors.


The name of a tab that this menu item will activate. Not compatible with href.


An link address. Not compatible with tabName.


If href is supplied, should the link open in a new browser tab?


If TRUE, this menuItem or menuSubItem will start selected. If no item have selected=TRUE, then the first menuItem will start selected.


A unique name given to each menuItem that serves to indicate which one (if any) is currently expanded. (This is only applicable to menuItems that have children and it is mostly only useful for bookmarking state.)


Should this menuItem be expanded on app startup? (This is only applicable to menuItems that have children, and only one of these can be expanded at any given time).


Menu items (and similarly, sub-items) should have a value for either href or tabName; otherwise the item would do nothing. If it has a value for href, then the item will simply be a link to that value.

If a menuItem has a non-NULL tabName, then the menuItem will behave like a tab – in other words, clicking on the menuItem will bring a corresponding tabItem to the front, similar to a tabPanel. One important difference between a menuItem and a tabPanel is that, for a menuItem, you must also supply a corresponding tabItem with the same value for tabName, whereas for a tabPanel, no tabName is needed. (This is because the structure of a tabPanel is such that the tab name can be automatically generated.) Sub-items are also able to activate tabItems.

Menu items (but not sub-items) also may have an optional badge. A badge is a colored oval containing text.

See Also

dashboardSidebar for example usage. For dynamically-generated sidebar menus, see renderMenu and sidebarMenuOutput.

Other sidebar items: sidebarSearchForm, sidebarUserPanel

rstudio/shinydashboard documentation built on Oct. 19, 2018, 11:32 p.m.