How to show Spinning Wheel or Busy Icon while waiting in Shiny

20,263

There is wonderful shinycssloaders package https://github.com/andrewsali/shinycssloaders, now maintained here https://github.com/daattali/shinycssloaders, which does what you want:

library(shiny)
library(dplyr)
library(shinycssloaders)

ui <- fluidPage(
  
  actionButton("plot","plot"),
  plotOutput("Test") %>% withSpinner(color="#0dc5c1")
)



server <- function(input, output, session) {
  

  data <- eventReactive(input$plot,{
    rnorm(1:100000)
  })
  
  output$Test <- renderPlot({
    plot(data())
  })
}

shinyApp(ui = ui, server = server)

enter image description here

Share:
20,263

Related videos on Youtube

Danish Zahid Malik
Author by

Danish Zahid Malik

Updated on July 09, 2022

Comments

  • Danish Zahid Malik
    Danish Zahid Malik almost 2 years

    Hey i've just started working with R and Shiny. Trying to make a dashboard which displays different charts. As there is a lot of data to process, the plots or charts take some time to display after the action button is clicked i.e. "launch Campaign' Is there anyway i could show a spinning wheel or a loading icon in the white blank space, while this delay takes place? Dashboard with blank space on the right

  • agent18
    agent18 almost 5 years
    works with textOutput as well. Great Stuff! textOutput("t1")%>% withSpinner(color="#0dc5c1")
  • bodega18
    bodega18 over 2 years
    dreamrs.github.io/shinybusy IMO this is the easiest solution. Requires only one line of code