Learn R Programming

yonder (version 0.1.0)

progressOutlet: Progress bars

Description

Create simple or composite progress bars. To create a composite progress bar pass multiple calls to bar to a progress output. Each bar component has its own id, value, label, and attributes. Furthermore, utility functions may be applied to individual bars for added customization.

Usage

progressOutlet(id, ...)

bar(id, value, label = NULL, striped = FALSE, ...)

showBar(outlet, bar, session = getDefaultReactiveDomain())

Arguments

id

A character string specifying the id of the progress outlet or progress bar.

For bar, specifying an id allows you to update an existing bar in a progress outlet with showBar(). If id is NULL, showBar() will append instead of replace a progress bar.

...

For progressOutlet, one or more bar elements to include by default.

For progressOutlet and bar, additional named arguments passed as HTML attributes to the parent element.

value

An integer between 0 and 100 specifying the initial value of a bar.

label

A character string specifying the label of a bar, defaults to NULL, in which case a label is not added.

striped

If TRUE, the progress bar has a striped gradient, defaults to FALSE.

outlet

A character string specifying the id of a progress outlet.

bar

A bar element, typically a call to bar().

session

A reactive context, defaults to getDefaultReactiveDomain().

Example application

ui <- container(
  progressOutlet("tasks"),
  buttonInput(
    id = "inc",
    "Increment progress"
  ) %>%
    margin(top = 3)
) %>%
  flex(direction = "column")

server <- function(input, output) { observeEvent(input$inc, ignoreInit = TRUE, { showBar( id = "tasks", bar( id = "laundry", value = min(100, input$inc * 10) ) %>% background("amber") ) }) }

shinyApp(ui, server)

See Also

Other content: alert, badge, blockquote, card, collapsiblePane, d1, dropdown, img, jumbotron, modal, navContent, popover, pre, toast, tooltip

Examples

Run this code
# NOT RUN {
### Striped variant

progressOutlet(
  id = "progress1",
  bar(
    id = "task1",
    value = 41,
    striped = TRUE  # <-
  ) %>%
    background("blue")
)

### Labeled bars

progressOutlet(
  id = "progress2",
  bar(
    id = "task2",
    value = 64,
    label = "Trees planted"  # <-
  ) %>%
    background("green")
)

### Multiple bars

progressOutlet(
  id = "progress3",
  bar(
    id = "task3",
    value = 40
  ) %>%
    background("red"),
  bar(
    id = "task4",
    value = 20
  ) %>%
    background("orange")
)

# }

Run the code above in your browser using DataLab