Description Usage Arguments Examples
Add a spinner that shows when an output is recalculating
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | withSpinner(
ui_element,
type = getOption("spinner.type", default = 1),
color = getOption("spinner.color", default = "#0275D8"),
size = getOption("spinner.size", default = 1),
color.background = getOption("spinner.color.background"),
custom.css = FALSE,
proxy.height = NULL,
id = NULL,
image = NULL,
image.width = NULL,
image.height = NULL,
hide.ui = TRUE
)
|
ui_element |
A UI element that should be wrapped with a spinner when the corresponding output is being calculated. |
type |
The type of spinner to use, valid values are integers between 0-8 (0 means no spinner). Check out
https://daattali.com/shiny/shinycssloaders-demo to see the different types of spinners. You can also use
your own custom image using the |
color |
The color of the spinner in hex format. Ignored if |
size |
The size of the spinner, relative to its default size (default is 1, a size of 2 means twice as large). Ignored if |
color.background |
For certain spinners (type 2-3), you will need to specify the background color of the spinner. Ignored if |
custom.css |
Set to |
proxy.height |
If the output UI doesn't specify the output height, you can set a proxy height. It defaults to "400px"
for outputs with undefined height. Ignored if |
id |
The HTML ID to use for the spinner. If you don't provide one, it will be generated automatically. |
image |
The path or URL of the image to use if you want to use a custom image instead of a built-in spinner. |
image.width |
The width for the custom image spinner, in pixels. If not provided, then the original
size of the image is used. Ignored if not using |
image.height |
The height for the custom image spinner, in pixels. If not provided, then the original
size of the image is used. Ignored if not using |
hide.ui |
By default, while an output is recalculating, the output UI is hidden and the spinner is visible instead.
Setting |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
actionButton("go", "Go"),
withSpinner(plotOutput("plot"))
),
server = function(input, output) {
output$plot <- renderPlot({
input$go
Sys.sleep(1.5)
plot(runif(10))
})
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.