rstudio / shinydashboard

Shiny Dashboarding framework
https://rstudio.github.io/shinydashboard/
Other
887 stars 299 forks source link

request: update box properties #287

Open r2evans opened 5 years ago

r2evans commented 5 years ago

It would be nice to be able to change the title= or status= of a box based on another event.

ui <- dashboardPage(
  dashboardHeader(title="Hello World"),
  dashboardSidebar(
    box(
      id="box001",
      title="Temporary", status="warning",
      ...
    )
  ),
  dashboardBody(
    ...
  )
)
server <- function(input, output, session) {
  observeEvent(input$xyz, {
    updateBox("box001", title="Updated", status="success")
  })
}

It might require js to make change CSS real-time (e.g., by changing .box.box-solid.box-primary>.box-header).

zx8754 commented 5 years ago

Any workarounds? Here is a relevant SO post:

https://stackoverflow.com/questions/51725295/r-shiny-color-of-boxes-depend-on-select

r2evans commented 5 years ago

I like the renderUI suggestion as a workaround. If the box has anything "expensive" in it then this could be a little heavy-handed, but most of my use-case was simpler.

Thanks for making the connection :-)