I have the shiny
app below in which I try to color the boxes based on 2 if
conditions but I cannot make it change.
## app.R ##
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
uiOutput("box1"),
uiOutput("box2")
)
)
server <- function(input, output) {
output$box1<-renderUI({
if(nrow(iris)==150){
tags$style(
type = 'text/css',
".box-danger{border-top-style: none; border-left-color: green; border-left-style: solid;}"
)
box(
title = "title",
closable = TRUE,
width = 10,
status = "danger",
solidHeader = F,
collapsible = TRUE,
collapsed = T
)
}
else{
tags$style(
type = 'text/css',
".box-danger{border-top-style: none; border-left-color: red; border-left-style: solid;}"
)
box(
title = "title",
closable = TRUE,
width = 10,
status = "danger",
solidHeader = F,
collapsible = TRUE,
collapsed = T
)
}
})
output$box2<-renderUI({
if(nrow(mtcars)==32){
tags$style(
type = 'text/css',
".box-danger{border-top-style: none; border-left-color: green; border-left-style: solid;}"
)
box(
title = "title",
closable = TRUE,
width = 10,
status = "danger",
solidHeader = F,
collapsible = TRUE,
collapsed = T
)
}
else{
tags$style(
type = 'text/css',
".box-danger{border-top-style: none; border-left-color: red; border-left-style: solid;}"
)
box(
title = "title",
closable = TRUE,
width = 10,
status = "danger",
solidHeader = F,
collapsible = TRUE,
collapsed = T
)
}
})
}
shinyApp(ui, server)