title: How to programmatically collapse a box in shiny dashboard
body: <p>I'm trying to collapse a box programmatically when an input changes. It seems that I only need to add the class <code>&quot;collapsed-box&quot;</code> to the box, I tried to use the shinyjs function <code>addClass</code>, but I don't know how to do that becuase a box doesn't have an <code>id</code>. Here as simple basic code that can be used to test possible solutions:</p>
  <pre><code>library(shinydashboard)
  
  ui &lt;- dashboardPage(
    dashboardHeader(),
    dashboardSidebar(),
    dashboardBody(
        box(collapsible = TRUE,p(&quot;Test&quot;)),
        actionButton(&quot;bt1&quot;, &quot;Collapse&quot;)
    )
  )
  
  server &lt;- function(input, output) {
    observeEvent(input$bt1, {
      # collapse the box
    })
  }
  
  shinyApp(ui, server)
  </code></pre>