R shinyDashboard customize box status color

后端 未结 3 1937
野性不改
野性不改 2020-12-24 15:11

I would like to customize the color of the box status of my shiny app. I find a css way to change the box background color of these box but not to customize the status colo

3条回答
  •  别那么骄傲
    2020-12-24 15:33

    This is brilliant and worked really well for me! I just wanted to add that there is a small bit of code you can add if you want to be able to use the new color with solidHeader = FALSE (to get at Dmitri's question). You need to change the color of the text in the header (I am now using black) and my new 'status' is purple. Here is an example below (where I am replacing the danger status rather than primary):

    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      dashboardHeader(),
      dashboardSidebar(),
      dashboardBody(
        tags$style(HTML("
    
    
    .box.box-solid.box-danger>.box-header {
      color:#fff;
      background:#9966ff
                        }
    
    .box.box-solid.box-danger{
    border-bottom-color:#9966ff;
    border-left-color:#9966ff;
    border-right-color:#9966ff;
    border-top-color:#9966ff;
    }
    
    .box.box-danger>.box-header {
      color:#000000;
      background:#fff
                        }
    
    .box.box-danger{
    border-bottom-color:#9966ff;
    border-left-color:#9966ff;
    border-right-color:#9966ff;
    border-top-color:#9966ff;
    }
    
                                        ")),
        fluidRow(
          box(width = 6, title = "youhou", status = "danger", solidHeader = FALSE,
              "Box content"
          )
        )
      )
    )
    
    
    server <- function(input, output) {}
    
    shinyApp(ui, server)
    

    (I found the right argument for this kind of box by following the OP's instructions to display all the css parameters.)

提交回复
热议问题