Shiny app-show some message while user is waiting for output

Hi everyone, is it possible to allow shiny to show some messages while user are waiting for the result of the computation? For example, for a function that would take a long time, a user would see this, which is something gray. However, I want to user to know more about what is going on, such as showing "Computing XXX", like what we would see on a well designed web app. I know an error or a warning would be shown on the screen, but is there any other way besides them?
image
It would be even better if some loading anime can be shown.

The following displays a spinning orange cog when shiny tells the browser that it is busy. Feel free to customize it as needed and replace fa fa-spinner fa-pulse fa-fw with any other font awesome animation https://fontawesome.com/how-to-use/on-the-web/styling/animating-icons

shiny_busy <- function() {
  # use &nbsp; for some alignment, if needed
  HTML("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", paste0(
    '<span data-display-if="',
    '$(&#39;html&#39;).attr(&#39;class&#39;)==&#39;shiny-busy&#39;',
    '">',
    '<i class="fa fa-spinner fa-pulse fa-fw" style="color:orange"></i>',
    '</span>'
  ))
}

# call from shiny ui with
shiny_busy()
2 Likes

Thank you Mike! I am not very familiar with CSS but is there a way to adjust the size of the spinner?

Change style to something like style="color:orange; font-size:30px"

@trcc , I can't tell for sure, but also look into https://shiny.rstudio.com/reference/shiny/latest/freezeReactiveValue.html to remove the temporary state of 'argument is not a matrix'.