简体   繁体   中英

How to change background color and text color of a titlePanel in R Shiny?

I'm having trouble changing the background color and text color in my Shiny dashboard and the videos and sites that I've looked at have been no help as what they say to do is giving me an error. My code is:

ui <- fluidPage(
  titlePanel(HTML("<center>This Is My Title</center>"),
             tags$style(
                background-color: "blue",
                color: "white")
))

As you can see, I am trying to make the text color white and the background for only the title to be blue. If anyone can help that would be much appreciated.

titlePanel("This is my title")
tags$style(HTML("
    body {
            background-color: Black;
            color: white;
            }"))

You can use titlePanel to set your title in shiny instead of wrapping in HTML, and then for the CSS, it needs to be completely wrapped by HTML() and Quotes for it to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM