Learn R Programming

yonder (version 0.0.5)

badgeOutput: Badge outputs

Description

Small highlighted content which scales to its parent's size. Useful for displaying dynamically changing counts or tickers, drawing attention to new options, or tagging content.

Usage

badgeOutput(id, ...)

renderBadge(expr, env = parent.frame(), quoted = FALSE)

Arguments

id

A character string specifying the id of the output.

...

Additional named argument passed as HTML attributes to the parent element.

expr

An expression which returns a character string specifying the label of the badge.

env

The environment in which to evaluate expr, defaults to the calling environment.

quoted

One of TRUE or FALSE specifying if expr is a quoted expression.

Examples

Run this code
# NOT RUN {
## Buttons with badges

# Typically, you would use `renderBadge()` to update a badge's
# value. Here we are hard-coding a default value of 7.

buttonInput(
  id = NULL,
  label = "Process",
  badgeOutput(
    id = NULL,
    7
  ) %>%
    background("cyan")
)

## Possible colors

colors <- c(
  "red", "purple", "indigo", "blue", "cyan", "teal", "green",
  "yellow", "amber", "orange", "grey", "white"
)

div(
  lapply(
    colors,
    function(color) {
      badgeOutput(
        id = NULL,
        color
      ) %>%
        background(color) %>%
        margin(2)
    }
  )
) %>%
  display("flex") %>%
  flex(wrap = TRUE)

# }

Run the code above in your browser using DataLab