Learn R Programming

cascadess (version 0.1.0)

background: Backgrounds

Description

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

Usage

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<U+2019>s action buttons.

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

Take action

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

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

Take action

Shiny<U+2019>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"
  )
)

It<U+2019>s alive

It<U+2019>s panel

Colors

blue

indigo

purple

red

orange

yellow

green

teal

cyan

white

transparent

Examples

Run this code
# NOT RUN {
library(htmltools)

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

# }

Run the code above in your browser using DataLab