Skip to contents

Wraps a 'Lottie' animation within a button element for use in 'shiny' applications.

Usage

lottie_button(
  animation,
  inputId,
  label = NULL,
  width = NULL,
  height = NULL,
  ...
)

Arguments

animation

A 'Lottie' animation created by lottie_animation.

inputId

The 'shiny' input slot that will be used to access the value.

label

Optional text label to display below the animation inside the button.

width

Width of the button. This is validated using validateCssUnit.

height

Height of the button. This is validated using validateCssUnit.

...

Additional named attributes to pass to the button element. Same behaviour as actionButton.

Value

An HTML button element enclosing the animation input object.

Examples

if (FALSE) { # interactive()
library(shiny)
library(shinyLottie)

ui <- fluidPage(
  include_lottie(),
  lottie_animation(
    path = "shinyLottie/example.json",
    name = "my_animation",
    height = "100px",
    width = "100px"
  ) |> lottie_button(inputId = "my_button")
)

server <- function(input, output, session) {
  observeEvent(input$my_button, {
    print("Button pressed")
  })
}

shinyApp(ui, server)
}