Getting rid of the renderUI

  1. Combine all together in a new app.
library(shiny)
library(shinyWidgets)
library(OSUICode)

ui <- fluidPage(
  # import shinydashboard deps without the need of the
  # dashboard template
  useShinydashboard(),

  tags$style("body { background-color: ghostwhite};"),

  br(),
  box2(id = "mybox",
       title = "Box",
       width = 6,
       "Box body",
       background = "blue"),
  
  br(),
  br(),
  selectInput(
    "widthvalue",
    "Width Value",
    choices = 6:12
  )
)

server <- function(input, output, session) {

  dummy_task <- reactive({
    Sys.sleep(5)
    input$widthvalue
  })

  observeEvent(dummy_task(), {
    updateBox2(
      "mybox",
      action = "update",
      options = list(
        width = dummy_task()
      )
    )
  })
}

shinyApp(ui, server)