Reputation: 744
I'm making my first shiny application and am having trouble linking an external css file. I've seen a few references where people have explained how to do it and even showed example code, but I haven't had any luck. Most of the example I've seen it working used the bootstrapPage, like this:
shinyUI(bootstrapPage(
tags$head(
tags$title('Example linked stylesheet'),
tags$link(rel = 'stylesheet', type = 'text/css', href = 'assets/ace-shiny.css'),
))
I'm using fluidPage, and don't know if that's my problem. My attempt is below. I've confirmed that my working directory is where I think it is, and contains the "Assets" folder which holds the css file. I know the tags$head
bit is working, since if I uncomment the tags$style
there, it gets applied.
shinyUI(fluidPage(
tags$head(
tags$link(rel="stylesheet", type="text/css", href="assets/styles.css")
#tags$style(type='text/css', "body {background-color: black;}")
))
My CSS at this stage is simple (below), so I know it's not the problem.
body {background-color: red;}
Am I missing something obvious? Thanks for reading. Mike
Upvotes: 2
Views: 2863
Reputation: 12654
You need to put your .css
file in a subdirectroy called www
NOTE
As gruvn mentioned in the comments, you need to make your href
just refer to the files, and not include the www
path. That is, use href='mycss.css'
and not href='www/mycss.css'
Upvotes: 3