Shiny R不读取自定义CSS文件

时间:2018-06-12 18:46:26

标签: css r shiny themes

我能够成功使用闪亮的自定义主题,即

# Internal, hidden function
# Called by CherryPickPalette()
CustomPal <- function(new_pal){
  if (interactive()){
    cherrypickedpalette <- runApp(list(
      ui = fluidPage(
        theme = shinythemes::shinytheme("slate"),

将为app提供以下外观

enter image description here

但是如果我用自定义.css替换,程序会忽略它,即

自定义CSS, h5.css

h5 {
color: orange;
text-align: center;
}

使用 h5.css

的代码
# Internal, hidden function
# Called by CherryPickPalette()
CustomPal <- function(new_pal){
  if (interactive()){
    cherrypickedpalette <- runApp(list(
      ui = fluidPage(
        theme = "h5.css",
        titlePanel("Cherry Pick Your Own Palette!"),
        sidebarPanel (hr(),
                      selectInput('col', 'Options', new_pal, multiple=TRUE, selectize=FALSE, size = 15)
        ),
        mainPanel(
          h5('Your Cherry-Picked Palette'),
          fluidRow(column(12,verbatimTextOutput("col"))),

h5文本,即“你的Cherry-Picked Palette”不受影响。

R目录结构为here

请帮忙!

enter image description here

1 个答案:

答案 0 :(得分:1)

我不确定为什么它不适用于此目录结构,但您可以尝试使用:

ui = fluidPage(
       # theme = "h5.css",
       tags$head(includeCSS("R/www/h5.css")),
       titlePanel("Cherry Pick Your Own Palette!"),
       ...
)