showF7Preloader shows a preloader.

f7HidePreloader hides a preloader.

showF7Preloader(
  target = NULL,
  color = NULL,
  session = shiny::getDefaultReactiveDomain()
)

f7HidePreloader(target = NULL, session = shiny::getDefaultReactiveDomain())

Arguments

target

Element where preloader overlay will be added.

color

Preloader color.

session

Shiny session object.

Examples

if (interactive()) {
 library(shiny)
 library(shinyMobile)

 # basic preloader with red color
 shinyApp(
  ui = f7Page(
    title = "Preloader",
    f7SingleLayout(
      navbar = f7Navbar(
        title = "Preloader",
        hairline = FALSE,
        shadow = TRUE
      ),
      # main content
      f7Button("showLoader", "Show loader"),
      f7Shadow(
        intensity = 10,
        hover = TRUE,
        f7Card(
          title = "Card header",
          f7Slider("obs", "Number of observations", 0, 1000, 500),
          plotOutput("distPlot")
        )
      )
    )
  ),
  server = function(input, output, session) {
    output$distPlot <- renderPlot({
      dist <- rnorm(input$obs)
      hist(dist)
    })

    observeEvent(input$showLoader, {
      showF7Preloader(color = "red")
      Sys.sleep(2)
      f7HidePreloader()
    })
  }
 )

 # preloader in container
 shinyApp(
  ui = f7Page(
    title = "Preloader in container",
    f7SingleLayout(
      navbar = f7Navbar(
        title = "Preloader in container",
        hairline = FALSE,
        shadow = TRUE
      ),
      # main content
      f7Shadow(
        intensity = 10,
        hover = TRUE,
        f7Card(
          title = "Card header",
          f7Slider("obs", "Number of observations", 0, 1000, 500),
          plotOutput("distPlot")
        )
      ),
      f7Card("This is a simple card with plain text,
       but cards can also contain their own header,
       footer, list view, image, or any other element.")
    )
  ),
  server = function(input, output, session) {
    output$distPlot <- renderPlot({
      dist <- rnorm(input$obs)
      hist(dist)
    })

    observeEvent(input$obs, {
      showF7Preloader(target = "#distPlot", color = "red")
      Sys.sleep(2)
      f7HidePreloader()
    })
  }
 )
}