Closed RoryChenXY closed 6 months ago
library(shiny)
csvDownloadButton <- function(id, filename = "data.csv", label = "Download as CSV") {
tags$button(
# Button class
class="btn btn-default action-button shiny-bound-input",
# Adding icon and label
tagList(icon("download"), label),
# Download csv
onclick = sprintf("Reactable.downloadDataCSV('%s', '%s')", id, filename),
)
}
ui <- fluidPage(
csvDownloadButton("cars_table"),
reactableOutput("cars_table")
)
server <- function(input, output) {
output$cars_table <- renderReactable({
reactable(MASS::Cars93)
})
}
shinyApp(ui, server)
Can you please provide an example of using the JS API within R shiny app? Huge thanks!