Picture as a background of shiny for aspecific tabPanel

Viewed 86

I want to set a picture as a background for a specific tabPanel in R shiny. The picture in my browser('data/image1.jpg') not from the internet. Could you please assist me on this regard

library(shiny)
ui <- 
navbarPage("App Title",
               tabPanel("Plot"),# for example I need the background here for Plot tabPanel
               tabPanel("Summary"),
               tabPanel("Table")
)

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


shinyApp(ui, server) 
1 Answers

You can use a selector based on the panel attribute data-value="Plot".

library(shiny)
ui <- 
  navbarPage("App Title",
             tags$style(
               'div[data-value="Plot"]{
                 height: 400px;
                 background-image: url(https://cdn.pixabay.com/photo/2015/04/19/08/32/marguerite-729510_960_720.jpg);
               }'
             ),
             tabPanel("Plot"),# for example I need the background here for Plot tabPanel
             tabPanel("Summary"),
             tabPanel("Table")
  )

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


shinyApp(ui, server) 

enter image description here

Related