useBusyIndicators: Enable/disable busy indication

View source: R/busy-indicators.R

useBusyIndicatorsR Documentation

Enable/disable busy indication

Description

Busy indicators provide a visual cue to users when the server is busy calculating outputs or otherwise performing tasks (e.g., producing downloads). When enabled, a spinner is shown on each calculating/recalculating output, and a pulsing banner is shown at the top of the page when the app is otherwise busy. Busy indication is enabled by default for UI created with bslib, but must be enabled otherwise. To enable/disable, include the result of this function in anywhere in the app's UI.

Usage

useBusyIndicators(..., spinners = TRUE, pulse = TRUE, fade = TRUE)

Arguments

...

Currently ignored.

spinners

Whether to show a spinner on each calculating/recalculating output.

pulse

Whether to show a pulsing banner at the top of the page when the app is busy.

fade

Whether to fade recalculating outputs. A value of FALSE is equivalent to busyIndicatorOptions(fade_opacity=1).

Details

When both spinners and pulse are set to TRUE, the pulse is automatically disabled when spinner(s) are active. When both spinners and pulse are set to FALSE, no busy indication is shown (other than the graying out of recalculating outputs).

See Also

busyIndicatorOptions() for customizing the appearance of the busy indicators.

Examples



library(bslib)

ui <- page_fillable(
  useBusyIndicators(),
  card(
    card_header(
      "A plot",
      input_task_button("simulate", "Simulate"),
      class = "d-flex justify-content-between align-items-center"
    ),
    plotOutput("p"),
  )
)

server <- function(input, output) {
  output$p <- renderPlot({
    input$simulate
    Sys.sleep(4)
    plot(x = rnorm(100), y = rnorm(100))
  })
}

shinyApp(ui, server)


shiny documentation built on Sept. 11, 2024, 7:24 p.m.