Reputation: 11
Is it possible to change the validcolor of a box in R Shiny
?
Is there a function for it? Al the boxes that I want to make have to be a customized color. So HTML does not do the trick for me.
I have tried black <- c("#e9e9e9")
with box(xxxxxxx, background = black)
without ""
then I'll get a
error: #e9e9e9 It is not a validcolor has to 'red' and so on.
Thanks for the help.
Upvotes: 1
Views: 4291
Reputation: 3000
Open your program in the browser and use the developer tools to find the variables that represent your "box" in HTML, once you know this they are easy to color.
We can input HTML directly into shiny using tags$head(
For this example, I color the main well of my sidebar panel, you can create colors here https://pikock.github.io/bootstrap-magic/app/index.html#!/editor
Note that .well is the name of the HTML module I want to style. Yours will be different.
tags$head(
# Styling Well
tags$style(type = 'text/css','.well {
background-color: #00244a;
}'
)
To really understand how to do it yourself, see https://shiny.rstudio.com/articles/html-tags.html & R shiny - background of sidebar panel
Note: The reason you are getting these errors is you are passing an HTML color into R without notifying Shiny to use HTML code, therefore black, red, and all the other R default colors are all that are available.
Upvotes: 2