library(shiny) library(shinyBS) app = shinyApp( ui = fluidPage( sidebarLayout( sidebarPanel( HTML("This button will open and close Panel 1 without using any R code."), actionButton( inputId="p1Button", "Push Me!", class="btn btn-primary", type="button", "data-toggle"="collapse", "data-target"="#panel-1", "aria-expanded"="false", "aria-controls"="collapseExample" ), selectInput( "styleSelect", "Select style for Panel 1", c("default", "primary", "danger", "warning", "info", "success")) ), mainPanel( bsCollapse( id = "collapseExample", open = "Panel 2", bsCollapsePanel( id="panel-1", title="Panel 1", "This is a panel with just text ", "and has the default style. You can change the style in ", "the sidebar.", style = "info"), bsCollapsePanel( id="panel-2", title="Panel 2", "This panel has a generic plot. ", "and a 'success' style.", plotOutput("genericPlot"), style = "success") ) ) ) ), server = function(input, output, session) { output$genericPlot <- renderPlot(plot(rnorm(100))) observeEvent(input$styleSelect, ({ updateCollapse(session, "collapseExample", style = list("Panel 1" = input$styleSelect)) })) } )