Skip to contents

The background_color() and background_subtle() functions adjust the background color of a tag element.

Usage

background_color(x, color)

background_subtle(x, color)

Arguments

x

A tag element or .style pronoun.

color

A character string specifying a color. One of,

  • "primary"

  • "secondary"

  • "success"

  • "danger"

  • "warning"

  • "info"

  • "light"

  • "dark"

Value

An object of the same type as x.

Examples


library(htmltools)

div(
  .style %>%
    background_color(theme_primary()),
  "Primary background"
)
#> <div class="bg-primary">Primary background</div>

div(
  .style %>%
    background_color(theme_danger()),
  "Danger background"
)
#> <div class="bg-danger">Danger background</div>

div(
  .style %>%
    background_subtle(theme_warning()) %>%
    border_subtle(theme_warning()) %>%
    text_emphasis(theme_warning()),
  "Warning!"
)
#> <div class="bg-warning-subtle border-warning-subtle text-warning-emphasis">Warning!</div>


div(
  .style %>%
    background_subtle(theme_dark()) %>%
    border_subtle(theme_dark())
)
#> <div class="bg-dark-subtle border-dark-subtle"></div>