How to make a gradient box closable in shiny

204 Views Asked by At

Now intially the box is open instead of that i need the box should be closed. The box should't open untill i click on the collapsible

library(shiny)
     library(shinydashboard)
     shinyApp(
      ui = dashboardPage(
        dashboardHeader(),
        dashboardSidebar(),
        dashboardBody(
         gradientBox(
          title = "My gradient Box",
          icon = "fa fa-th",
          gradientColor = "teal", 
          boxToolSize = "sm", 
          footer = sliderInput(
           "obs", 
           "Number of observations:",
            min = 0, max = 1000, value = 500
           ),
          "This is a gradient box"
          )
        ),
        title = "Description Blocks"
      ),
      server = function(input, output) { }
     )
1

There are 1 best solutions below

0
On BEST ANSWER

There doesn't seem to be an argument in gradientBox that enables the box to be collapsed on startup.

Since {shinydashboardPlus} version 2.0.0 gradientBox has been removed and can use box instead. This has the argument collapsed which when true will start collapsed:

library(shiny)
library(shinydashboard)
library(shinydashboardPlus)

ui <- dashboardPage( 
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    box(
      "This is a gradient box",
      title = "My gradient Box",
      gradient = TRUE,
      background = "teal",
      collapsible = TRUE,
      collapsed = TRUE,
      boxToolSize = "sm",
      footer = sliderInput(
        "obs", 
        "Number of observations:",
        min = 0, 
        max = 1000, 
        value = 500
      )
    )
  ),
  title = "Description Blocks"
)

shinyApp(
    ui = ui,
    server = function(input, output) { }
)

If you cannot upgrade {shinydashboardPlus} then you can use boxPlus. It won't be able to use the gradient, but will still be able to start collapsed.