Including CSS file in R using shiny dashboard


#1

Hi,
I created stylesheet.css under www directory for my dashboard to create css file and I have included the following code in ui.R
shiny::tags$head(
shiny::tags$link(rel = “stylesheet”, type = “text/css”, href = “stylesheet.css”)

and in stylesheet.css
.main-header .logo {
font-family: “Georgia”, Times, “Times New Roman”, serif;
font-weight: bold;
font-size: 24px;
}

but I am getting error after executing the code, so how do I solve this?
ERROR: Expected tag to be of type li

Thanks


#2

The easiest way I found, is to add the link to the css file in the dashboardBody() function call, e.g.:

dashboardBody(
    # Include the custom styling
    tags$head(
      tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
    ),

    # Add the pages
    tabItems(
      first_page,
      second_page
    )
  )

Where exactly are you adding the tags$... snippet?


#3

Yeah , I got it now,

I added tag$… snippet in the dashboard header.

Thank you :smile: