如何修改闪亮主题的主题?

时间:2019-01-28 13:37:49

标签: shiny shinythemes

如何修改shinythemes的主题?例如,假设我们要更改darkly的背景黑色。

library(shiny)
library(shinythemes)

ui <- fluidPage(
  theme = shinytheme("darkly"),
  "How to change this black?")

server <- function(input, output) {}

shinyApp(ui, server)

我想一种解决方案是将darkly的CSS(带有经过修改的黑色)复制到我的应用程序的www文件夹中,然后使用theme = "darkly_modified_black.css"。我缺少一个更简单的解决方案吗?

1 个答案:

答案 0 :(得分:1)

如果只想更改背景颜色,则可以包含自己的css参数。 但是,是的,您还可以复制深色的css,进行修改,将其包含在www文件夹中,然后从那里加载。

library(shiny)
library(shinythemes)

css <- HTML(" body {
    background-color: #000000;
}")

ui <- fluidPage(
  tags$head(tags$style(css)),
  theme = shinytheme("darkly"),
  "How to change this black?")

server <- function(input, output) {}

shinyApp(ui, server)

如果您要使用单独的.css文件,则可以将includeCSS与文件路径一起使用。