如何创建自定义Shinydashboard皮肤

时间:2018-05-22 11:59:58

标签: r shinydashboard

我正在制作闪亮的仪表板,并希望皮肤上的颜色与闪亮文档中可用的颜色不同(skins available in shiny

我希望('#2666cc','rgb(38,102,204)')这种颜色在皮肤上。是否可以在闪亮的仪表板中使用?

Dashboard

想要突出显示区域的新颜色。

1 个答案:

答案 0 :(得分:3)

在您发布的链接中,有一个CSS部分,它解释了所有内容。但首先,这应该没问题。)

library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Custom font"),
  dashboardSidebar(
    # Custom CSS to hide the default logout panel
    tags$head(tags$style(HTML('.logo {
                              background-color: #2666cc !important;
                              }
                              .navbar {
                              background-color: #2666cc !important;
                              }
                              '))),

    # The dynamically-generated user panel
    uiOutput("userpanel")
  ),
  dashboardBody()
)

server <- function(input, output, session) {
  output$userpanel <- renderUI({
    # session$user is non-NULL only in authenticated sessions
    if (!is.null(session$user)) {
      sidebarUserPanel(
        span("Logged in as ", session$user),
        subtitle = a(icon("sign-out"), "Logout", href="__logout__"))
    }
  })
}

shinyApp(ui, server)