在Shinydashboard中更改颜色 [英] Change color in shinydashboard

查看:225
本文介绍了在Shinydashboard中更改颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下内容可以将Shinydashboard中主要状态的颜色更改为我所说的自定义蓝色.

I have the following which changes the color of the primary status in shinydashboard to the custom blue I have stated.

tags$style(HTML(".box.box-solid.box-primary>.box-header {
                                color:#FFFFFF;
                                background-color:#005CB9;}

                                .box.box-solid.box-primary{
                                border-bottom-color:#005CB9;
                                border-left-color:#005CB9;
                                border-right-color:#005CB9;
                                border-top-color:#005CB9;
                                }")),

但是,我需要更改信息框的颜色,因为它使用color =而不是status =.有人知道我需要更改以自定义Shinydashboard中默认颜色之一的标签吗?

However I need to change the color of an infobox as this uses color = instead of the status =. Does anyone know the tags I need to change to customise one of the default colors in shinydashboard?

谢谢

推荐答案

我在dashboardBody()标记的开头使用了以下style()语句,以您的自定义蓝色覆盖了color = "aqua"的每个实例:

I used the following style() statement at the beginning of the dashboardBody() tag to override every instance where color = "aqua" with your custom blue:

tags$style(
  type = 'text/css', 
  '.bg-aqua {background-color: #005CB9!important; }'
),

键是颜色后面的"!important",它会覆盖闪亮的仪表盘预设.

The key is the "!important" after the color, which overrides the shinydashboard preset.

将来,识别CSS类的一种简单方法是在运行Shinyapp时在Rstudio中选择外部运行",然后使用浏览器的开发人员工具或检查元素"工具.

In the future, an easy way to identify css classes is to select "run external" in Rstudio when running your shinyapp, then use your browser's developer tools or "inspect element" tools.

这是上下文的完整示例:

Here's the full example for context:

require(shiny)
require(shinydashboard)

ui <- shinyUI(dashboardPage(
  dashboardHeader(title = 'Change infoBox color'),
  dashboardSidebar(disable = TRUE),

  dashboardBody(
    tags$style(
      type = 'text/css', 
      '.bg-aqua {background-color: #005CB9!important; }'
    ),

    infoBox(
      title = 'Custom Color',
      value = 100,
      color = 'aqua'
    )
  )
))

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

})

shinyApp(ui, server)

这篇关于在Shinydashboard中更改颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆