Including css file in shiny

hi..i'm trying to get background image in my dashboard.. the following code i have included in ui

ui<-dashboardPage(
  dashboardHeader(title = "Hello"),
  dashboardBody(
    tags$head(
      tags$link(rel = "stylesheet", type = "text/css", href = "style.css")
    )
  )
)

and in my css

.main-header .logo {
  font-family: "Georgia", Times, "Times New Roman", serif;
  font-weight: bold;
  font-size: 24px;
}
body {
background-image: url("?C:\Users\InESS-SYS-11\Pictures\hi.jpg");
}

but there is no changes in my dashboard. can anyone help me thank you

where is your style.css file saved in your app directory? It may also have something to do with the ? at the beginning of your image file path, that seems out of place

The style.css file should be placed in a www folder that lives at the same level as your app.R file. You can move the image into this folder as well and update the path accordingly.

Also, I had to add a dashboardSidebar() between the header and body:

ui <- dashboardPage(
  dashboardHeader(title = "Hello"),
  dashboardSidebar(),
  dashboardBody(
    tags$head(
      tags$link(rel = "stylesheet", type = "text/css", href = "style.css")
    )
  )
)
3 Likes