Create a download button with actionBttn().
downloadBttn(
outputId,
label = "Download",
style = "unite",
color = "primary",
size = "md",
block = FALSE,
no_outline = TRUE,
icon = shiny::icon("download")
)The name of the output slot that the shiny::downloadHandler() is assigned to.
The contents of the button, usually a text label.
Style of the button, to choose between simple, bordered,
minimal, stretch, jelly, gradient, fill,
material-circle, material-flat, pill, float, unite.
Color of the button : default, primary, warning,
danger, success, royal.
Size of the button : xs,sm, md, lg.
Logical, full width button.
Logical, don't show outline when navigating with keyboard/interact using mouse or touch.
An optional icon to appear on the button.
if (interactive()) {
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Download bttn"),
downloadBttn(
outputId = "downloadData",
style = "bordered",
color = "primary"
)
)
server <- function(input, output, session) {
output$downloadData <- downloadHandler(
filename = function() {
paste('data-', Sys.Date(), '.csv', sep='')
},
content = function(con) {
write.csv(mtcars, con)
}
)
}
shinyApp(ui, server)
}