Skip to content

Commit 70d2aa5

Browse files
authored
examples to show how to apply css (#21)
1 parent cfb35c1 commit 70d2aa5

File tree

5 files changed

+75
-0
lines changed

5 files changed

+75
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
library(shiny)
2+
3+
ui <- fluidPage(
4+
# 1. EXTERNAL
5+
tags$link(rel = "stylesheet", type="text/css", href="style.css"),
6+
7+
tags$h2("Heading Level 2"),
8+
tags$p("This is a paragraph"),
9+
)
10+
11+
server <- function(input, output, session) {}
12+
13+
shinyApp(ui, server)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
library(shiny)
2+
3+
ui <- fluidPage(
4+
5+
# 2. INTERNAL
6+
tags$head(
7+
tags$style(
8+
"p {
9+
color: purple;
10+
}"
11+
)
12+
),
13+
14+
tags$h2("Heading Level 2"),
15+
tags$p("This is a paragraph"),
16+
)
17+
18+
server <- function(input, output, session) {}
19+
20+
shinyApp(ui, server)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
library(shiny)
2+
3+
ui <- fluidPage(
4+
5+
tags$h2("Heading Level 2"),
6+
tags$p("This is a paragraph"),
7+
8+
# 3. INLINE
9+
tags$p("Second paragraph", style = "color:darkgreen;")
10+
11+
)
12+
13+
server <- function(input, output, session) {}
14+
15+
shinyApp(ui, server)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
library(shiny)
2+
3+
# 4. DEPENDENCY
4+
color_dependency <- function() {
5+
htmltools::htmlDependency(
6+
name = "p_color",
7+
version = "1.0.0",
8+
src = "www/",
9+
stylesheet = "style.css"
10+
)
11+
}
12+
13+
ui <- fluidPage(
14+
15+
tags$h2("Heading Level 2"),
16+
tags$p("This is a paragraph")
17+
18+
)
19+
20+
ui_dep <- tagList(ui, color_dependency())
21+
22+
server <- function(input, output, session) {}
23+
24+
shinyApp(ui_dep, server)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
p {
2+
color: purple;
3+
}

0 commit comments

Comments
 (0)