【问题标题】:Change the title header color permanently in shiny dashboard在闪亮的仪表板中永久更改标题标题颜色
【发布时间】:2020-09-12 04:16:26
【问题描述】:

我有下面闪亮的仪表板,我需要永久更改包含标题的标题的颜色。现在,当我将鼠标悬停在它上面时,它会返回以前的颜色。

library(DT)
ui <- dashboardPage(
    dashboardHeader(title = "Dynamic sidebar"),
    dashboardSidebar(
        width=400
    ),
    dashboardBody(
        tags$head(tags$style(HTML('

        /* logo */
        .skin-blue .main-header .logo {
                              background-color: #E7FF6E;
                              }'))) 
    )
)

server <- function(input, output) {



}

shinyApp(ui, server)

【问题讨论】:

    标签: css r shiny shinydashboard


    【解决方案1】:

    您可以使用 {fresh} 包创建自定义主题以与 {shinydashboard} 一起使用,更多文档在这里:https://dreamrs.github.io/fresh/articles/vars-shinydashboard.html

    这里是修改标题背景颜色的示例:

    library(fresh)
    # Create the theme
    mytheme <- create_theme(
      adminlte_color(
        light_blue = "#E7FF6E"
      )
    )
    
    
    library(shiny)
    library(shinydashboard)
    
    ui <- dashboardPage(
      header = dashboardHeader(title = "My dashboard"),
      sidebar = dashboardSidebar(
        sidebarMenu(
          menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
          menuItem("Settings", tabName = "settings", icon = icon("sliders"))
        )
      ),
      body = dashboardBody(
    
        use_theme(mytheme) # <-- use the theme
      )
    )
    
    server <- function(input, output, session) {
    
    }
    
    shinyApp(ui, server)
    

    【讨论】:

    • 您知道为什么我在使用您的解决方案后无法更改侧边栏的宽度吗?它始终保持不变。
    • 哦,我找到了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-14
    • 2020-12-10
    • 1970-01-01
    • 2015-10-21
    • 2021-05-19
    • 2018-02-24
    相关资源
    最近更新 更多