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

View source: R/wrappers.R

add_stylesheetR Documentation

Add external (CSS) stylesheets to a Dash app

Description

Add external (CSS) stylesheets to a Dash app

Usage

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

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 June 23, 2022, 9:11 a.m.