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)
})
}
)
}
Run the code above in your browser using DataLab