controlbar: AdminLTE2 dashboard right sidebar

Description Usage Arguments Note Author(s) Examples

Description

dashboardControlbar create a right sidebar container.

updateControlbar allows to toggle a dashboardControlbar.

controlbarMenu is a tabset panel for the dashboardControlbar.

controlbarItem is a tabPanel for the controlbarMenu.

updateControlbarMenu allows to programmatically change the currently selected controlbarItem on the client.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
dashboardControlbar(
  ...,
  id = NULL,
  disable = FALSE,
  width = 230,
  collapsed = TRUE,
  overlay = TRUE,
  skin = "dark",
  .list = NULL
)

updateControlbar(id, session = shiny::getDefaultReactiveDomain())

controlbarMenu(..., id = NULL, selected = NULL)

controlbarItem(title, ..., value = title, icon = NULL)

updateControlbarMenu(
  id,
  selected = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

...

slot for controlbarMenu. Not compatible with .items.

id

Controlbar id.

disable

If TRUE, the sidebar will be disabled.

width

Sidebar width in pixels. Numeric value expected. 230 by default.

collapsed

Whether the control bar on the right side is collapsed or not at start. TRUE by default.

overlay

Whether the sidebar covers the content when expanded. Default to TRUE.

skin

background color: "dark" or "light".

.list

Pass element here if you do not want to embed them in panels. Not compatible with ...

session

Shiny session object.

selected

Item to select.

title

Display title for tab

value

The value that should be sent when tabsetPanel reports that this tab is selected. If omitted and tabsetPanel has an id, then the title will be used.

icon

Optional icon to appear on the tab. This attribute is only valid when using a tabPanel within a navbarPage().

Note

Until a maximum of 5 controlbarItem! AdminLTE 2 does not support more panels.

Author(s)

David Granjon, dgranjon@ymail.com

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
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Controlbar example
if (interactive()) {
 library(shiny)
 library(shinydashboard)
 library(shinydashboardPlus)
 shinyApp(
   ui = dashboardPage(
     header = dashboardHeader(),
     sidebar = dashboardSidebar(),
     body = dashboardBody(),
     controlbar = dashboardControlbar(
      skin = "dark",
      controlbarMenu(
       id = "menu",
       controlbarItem(
        "Tab 1",
        "Welcome to tab 1"
       ),
       controlbarItem(
        "Tab 2",
        "Welcome to tab 2"
       )
      )
     ),
     title = "Right Sidebar"
   ),
   server = function(input, output) { }
 )
}

# Toggle the dashboard controlbar
if (interactive()) {
 library(shiny)
 library(shinydashboard)
 library(shinydashboardPlus)
 
 shinyApp(
   ui = dashboardPage(
     header = dashboardHeader(),
     sidebar = dashboardSidebar(),
     body = dashboardBody(
       actionButton(inputId = "controlbarToggle", label = "Toggle Controlbar")
     ),
     controlbar = dashboardControlbar(id = "controlbar")
   ),
   server = function(input, output, session) {
     
     observeEvent(input$controlbar, {
       if (input$controlbar) {
         showModal(modalDialog(
           title = "Alert",
           "The controlbar is opened.",
           easyClose = TRUE,
           footer = NULL
         ))
       }
     })
     
     observeEvent(input$controlbarToggle, {
       updateControlbar("controlbar")
     })
     
     observe({
       print(input$controlbar)
     })
   }
 )
}

# controlbar with controlbarMenu
if (interactive()) {
 library(shiny)
 library(shinydashboard)
 library(shinydashboardPlus)
 
 shinyApp(
   ui = dashboardPage(
     header = dashboardHeader(),
     sidebar = dashboardSidebar(),
     body = dashboardBody(),
     controlbar = dashboardControlbar(
      id = "controlbar",
      controlbarMenu(
       id = "menu",
       controlbarItem(
        "Tab 1",
        "Welcome to tab 1"
       ),
       controlbarItem(
        "Tab 2",
        "Welcome to tab 2"
       )
      )
     )
   ),
   server = function(input, output, session) {
     
     observeEvent(input$menu, {
       showModal(modalDialog(
         title = "Alert",
         sprintf(" %s is active", input$menu),
         easyClose = TRUE,
         footer = NULL
       ))
     })
   }
 )
}

# Update a controlbar menu
if (interactive()) {
 library(shiny)
 library(shinydashboard)
 library(shinydashboardPlus)
 
 shinyApp(
   ui = dashboardPage(
     header = dashboardHeader(),
     sidebar = dashboardSidebar(),
     body = dashboardBody(
      radioButtons("controller", "Controller", choices = c(1, 2, 3))
     ),
     controlbar = dashboardControlbar(
      id = "controlbar",
      controlbarMenu(
       id = "menu",
       controlbarItem(
         paste0("Tab", 1),
         paste("Welcome to tab", 1)
       ),
       controlbarItem(
         paste0("Tab", 2),
         paste("Welcome to tab", 2)
       ),
       controlbarItem(
         paste0("Tab", 3),
         paste("Welcome to tab", 3)
       )
      )
     )
   ),
   server = function(input, output, session) {
    observeEvent(input$controller, {
     updateControlbarMenu(
      "menu", 
      selected = paste0("Tab", input$controller)
     )
    })
   }
 )
}

shinydashboardPlus documentation built on Sept. 16, 2021, 1:06 a.m.