updatebs4Sidebar: Function to programmatically toggle the state of the sidebar

Description Usage Arguments Examples

View source: R/dashboardSidebar.R

Description

Function to programmatically toggle the state of the sidebar

Usage

1
updatebs4Sidebar(inputId, session)

Arguments

inputId

Sidebar id.

session

Shiny session object.

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
if (interactive()) {
 library(shiny)
 library(bs4Dash)
 
 shiny::shinyApp(
   ui = dashboardPage(
     controlbar_collapsed = FALSE,
     controlbar_overlay = TRUE,
     navbar = dashboardHeader(),
     sidebar = dashboardSidebar(inputId = "sidebar"),
     body = dashboardBody(
       actionButton(inputId = "controlbarToggle", label = "Toggle Sidebar")
     )
   ),
   server = function(input, output, session) {
     
     observeEvent(input$sidebar, {
       if (input$sidebar) {
         showModal(modalDialog(
           title = "Alert",
           "The sidebar is opened.",
           easyClose = TRUE,
           footer = NULL
         ))
       }
     })
     
     observeEvent(input$controlbarToggle, {
       updatebs4Sidebar(inputId = "sidebar", session = session)
     })
     
     observe({
       print(input$sidebar)
     })
   }
 )
}

RX-PBB/bs4Mash documentation built on April 11, 2020, 12:15 a.m.