dashboardSidebar | R Documentation |
A dashboard sidebar typically contains a sidebarMenu
, although
it may also contain a sidebarSearchForm
, or other Shiny inputs.
updateSidebar allows to toggle a dashboardSidebar on the client.
dashboardSidebar(
...,
disable = FALSE,
width = NULL,
collapsed = FALSE,
minified = TRUE,
id = NULL
)
updateSidebar(id, session = shiny::getDefaultReactiveDomain())
... |
Items to put in the sidebar. |
disable |
If |
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 |
minified |
Whether to slightly close the sidebar but still show item icons. Default to TRUE. |
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)
})
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.