Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading