【问题标题】:Change font-family with CSS in dashboardBody shinydashboard在 dashboardBody shinydashboard 中使用 CSS 更改字体系列
【发布时间】:2015-09-08 09:38:37
【问题描述】:

如何在闪亮的仪表板中为 tabItem 中的框更改字体系列?

我已经在dashboardBody 中包含了一些css 编码,改变了颜色和字体系列,但这仅链接到主标题:

body <- dashboardBody(
 tags$head(tags$style(HTML('
  .skin-blue .main-header .logo {
    font-family: "Calibri";
    font-weight: bold;
    font-size: 28px;
    background-color: #003D76;
  }
  .skin-blue .main-header .navbar {
    background-color: #0082D1;
  }
  
'))),

非常感谢您的帮助。

tabItem 的开头如下:

tabItems(
tabItem(tabName = "dashboard",
        fluidRow(
          box(
            title = strong("GPIM Liquidity Risk"), status = "primary", solidHeader = TRUE, width = 8,
            img(src = "gpim-signet.png", height = 80, width = 130),

【问题讨论】:

    标签: css r shiny shinydashboard


    【解决方案1】:

    您可以像这样更改主侧边栏的 css(我提供了一些选项以方便您)

    可复制示例如下(它是默认皮肤,所以如果你使用其他皮肤 - 你应该将 skin-blue 更改为其他皮肤):

        library(shiny)
    library(shinydashboard)
    ## ui
        ui <- dashboardPage(
          dashboardHeader(title="MPG Data"),
          dashboardSidebar(
            sidebarMenu(
              menuItem("MPG",tabName="mpg")
            )
          ),
          dashboardBody(
            #here's where you throw the css into the header
            tags$head(
              includeCSS(path = "www/style.css")
            ),
            tabItems(
              tabItem(tabName="mpg",
                      fluidRow(tableOutput("mpgTable"))
              )
            )
          )
        )
    
        ## server
        server <- function(input, output) {
          output$mpgTable <- renderTable({mpg})
        }
    
        ## launch dashboard 
        shinyApp(ui, server)
    

    css文件内容如下

    /* main sidebar */
            .skin-blue .main-sidebar {
                                  background-color: #f4b943;
                                  font-family: "Calibri";
                                  font-size:25px;
                                  line-height:1.42857143;
                                  color:#ebebeb;
                                  }
    

    希望对您有所帮助!

    【讨论】:

    • 丹尼尔!很高兴您找到了解决方案。我是 stackoverflow 的新手,steel 甚至没有评论的声誉,所以如果你认为我的回答是正确的 - 请标记它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-03
    • 2018-11-24
    • 1970-01-01
    • 2020-02-15
    • 2020-12-15
    • 2020-06-29
    • 1970-01-01
    相关资源
    最近更新 更多