dashboardSidebar: Create a dashboard sidebar.

Description Usage Arguments See Also Examples

View source: R/dashboardSidebar.R

Description

A dashboard sidebar typically contains a sidebarMenu, although it may also contain a sidebarSearchForm, or other Shiny inputs.

Usage

1
dashboardSidebar(..., disable = FALSE, width = NULL, collapsed = FALSE)

Arguments

...

Items to put in the sidebar.

disable

If TRUE, the sidebar will be disabled.

width

The width of the sidebar. This must either be a number which specifies the width in pixels, or a string that specifies the width in CSS units.

collapsed

If TRUE, the sidebar will be collapsed on app startup.

See Also

sidebarMenu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
## Only run this example in interactive R sessions
if (interactive()) {
header <- dashboardHeader()

sidebar <- dashboardSidebar(
  sidebarUserPanel("User Name",
    subtitle = a(href = "#", icon("circle", class = "text-success"), "Online"),
    # Image file should be in www/ subdir
    image = "userimage.png"
  ),
  sidebarSearchForm(label = "Enter a number", "searchText", "searchButton"),
  sidebarMenu(
    # Setting id makes input$tabs give the tabName of currently-selected tab
    id = "tabs",
    menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
    menuItem("Widgets", icon = icon("th"), tabName = "widgets", badgeLabel = "new",
             badgeColor = "green"),
    menuItem("Charts", icon = icon("bar-chart-o"),
      menuSubItem("Sub-item 1", tabName = "subitem1"),
      menuSubItem("Sub-item 2", tabName = "subitem2")
    )
  )
)

body <- dashboardBody(
  tabItems(
    tabItem("dashboard",
      div(p("Dashboard tab content"))
    ),
    tabItem("widgets",
      "Widgets tab content"
    ),
    tabItem("subitem1",
      "Sub-item 1 tab content"
    ),
    tabItem("subitem2",
      "Sub-item 2 tab content"
    )
  )
)

shinyApp(
  ui = dashboardPage(header, sidebar, body),
  server = function(input, output) { }
)
}

Example output

Attaching package: 'shinydashboard'

The following object is masked from 'package:graphics':

    box

shinydashboard documentation built on Sept. 30, 2021, 5:09 p.m.