background: Backgrounds

Description Usage Arguments Buttons Panels Colors Examples

View source: R/background.R

Description

The background() function adjusts the background color of a tag element.

Usage

1
background(x, color)

Arguments

x

A tag element or .style pronoun.

color

One of "blue", "indigo", "purple", "red", "orange", "yellow", "green", "teal", "cyan", "white", or "transparent" specifying the background color of the tag element.

Buttons

Use background() to modify shiny’s action buttons.

actionButton("id", "Take action") %>%
  background("green")
html_preserve /html_preserve

With a couple other functions we can take our improvement a step further.

actionButton("id", "Take action") %>%
  background("green") %>%
  border("green") %>%
  shadow("small")
html_preserve /html_preserve

Shiny’s download buttons include ..., so we can use the .style pronoun!

downloadButton(
  .style %>%
    background("white") %>%
    border("blue"),
  outputId = "dwnld",
  label = "Do a download",
  class = NULL
)

Panels

sidebarLayout(
  sidebarPanel(
    .style %>%
      background("blue"),
    "It's alive"
  ),
  mainPanel(
    .style %>%
      background("red"),
    "It's panel"
  )
)
html_preserve

It’s alive

It’s panel

/html_preserve

Colors

html_preserve

blue

indigo

purple

red

orange

yellow

green

teal

cyan

white

transparent

/html_preserve

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
library(htmltools)

div(
  .style %>%
    background("white") %>%
    border("blue") %>%
    text("white"),
  "Nunc porta vulputate tellus.",
  "Suspendisse potenti."
)

cascadess documentation built on Jan. 13, 2021, 5:10 p.m.