Description Usage Arguments Examples
View source: R/dashboardSidebar.R
Function to programmatically toggle the state of the sidebar
1 | updatebs4Sidebar(inputId, session)
|
inputId |
Sidebar id. |
session |
Shiny session object. |
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)
})
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.