R/dashboardSidebar.R
updateSidebar.Rd
Function to programmatically toggle the state of the sidebar
updateSidebar(id, session = shiny::getDefaultReactiveDomain())
id | Sidebar id. |
---|---|
session | Shiny session object. |
if (interactive()) { library(shiny) library(shinydashboard) library(shinydashboardPlus) shinyApp( ui = dashboardPage( header = dashboardHeader(), sidebar = dashboardSidebar(id = "sidebar"), body = dashboardBody( actionButton(inputId = "sidebarToggle", 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$sidebarToggle, { updateSidebar("sidebar") }) observe({ print(input$sidebar) }) } ) }