在闪亮的仪表板 titlePanel 中更改字体颜色

时间:2021-06-10 20:21:38

标签: r shiny

我试图将仪表板的标题设为红色,但是当我尝试在我的 titlePanel 中传递 style 参数时,我收到一个错误,指出该参数未使用。我做错了什么?

library(shiny)

# Define UI for application that draws a histogram
ui <- fluidPage(

    # Application title
    titlePanel("Old Faithful Geyser Data", style = "color: #FFFFFF"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            sliderInput("bins",
                        "Number of bins:",
                        min = 1,
                        max = 50,
                        value = 30)
        ),

        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot")
        )
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

错误如下:

Error in titlePanel("Old Faithful Geyser Data", style = "color: #FFFFFF") : 
  unused argument (style = "color: #FFFFFF")

1 个答案:

答案 0 :(得分:1)

将其包裹在 div

titlePanel(div("Old Faithful Geyser Data", style = "color: #FF0000"))