Background colour not coming in print preview of r shiny output

Viewed 239

R Shiny is perfectly showing the output. But, while trying to print the shiny output from the Chrome or Internet Explorer, I am not getting the background colours in the print preview also the page saved as pdf did not show the background colours. I have also kept the option to "Show Background".

library(shiny)

ui <- fluidPage(
h2("Text Background colour YELLOW not showing in Print Preview",
    style="background-color: yellow")
)

server <- function(input, output, session) {
}

shinyApp(ui, server)

Below are the screenshot:

This is the browser view of R Shiny output

This is the print preview

1 Answers

Adding the ‘!important’ to any css style you add to your application forces it to use this style rather than inheriting the style from somewhere and changing the background back to white.

library(shiny)

ui <- fluidPage(
  h2("Text Background colour YELLOW not showing in Print Preview",
     style="background-color: yellow!important")
)

server <- function(input, output, session) {
}

shinyApp(ui, server)
Related