Learn R Programming

shinyLottie (version 1.0.0)

lottie_button: Convert a 'Lottie' Animation to a Button

Description

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

Usage

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

Value

An HTML button element enclosing the animation input object.

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.

Examples

Run this code
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)
}

Run the code above in your browser using DataLab