add_stylesheet: Add external (CSS) stylesheets to a Dash app

Description Usage Arguments Examples

View source: R/wrappers.R

Description

Add external (CSS) stylesheets to a Dash app

Usage

1
add_stylesheet(app, stylesheet)

Arguments

app

A dash application created with dash_app().

stylesheet

A single stylesheet or a list of stylesheets. Each stylesheet is either a string (the URL), or a named list with href (the URL) and any other valid <link> tag attributes. See examples below. Note that this is only used to add external stylesheets, not local.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
app <- dash_app()

# Add a single stylesheet with URL
app %>% add_stylesheet("https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css")

# Add multiple stylesheets with URL
app %>% add_stylesheet(list(
  "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css",
  "https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"
))

# Add a single stylesheet with a list
app %>% add_stylesheet(
  list(
    href = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css",
    integrity = "sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
  )
)

# Add multiple stylesheets with both URL and list
app %>% add_stylesheet(
  list(
    "https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css",
    "https://fonts.googleapis.com/css?family=Lora",
    list(
      href = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.1/dist/css/bootstrap.min.css",
      integrity = "sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x"
    )
  )
)

dash documentation built on Nov. 7, 2021, 9:06 a.m.