Winston Chang [aut] (ORCID: <https://orcid.org/0000-0002-1576-2126>), Joe Cheng [aut], JJ Allaire [aut], Carson Sievert [aut, cre] (ORCID: <https://orcid.org/0000-0002-4958-2844>), Barret Schloerke [aut] (ORCID: <https://orcid.org/0000-0001-9986-114X>), Garrick Aden-Buie [aut] (ORCID: <https://orcid.org/0000-0002-7111-0077>), Yihui Xie [aut], Jeff Allen [aut], Jonathan McPherson [aut], Alan Dipert [aut], Barbara Borges [aut], Posit Software, PBC [cph, fnd] (ROR: <https://ror.org/03wc8by49>), jQuery Foundation [cph] (jQuery library and jQuery UI library), jQuery contributors [ctb, cph] (jQuery library; authors listed in inst/www/shared/jquery-AUTHORS.txt), jQuery UI contributors [ctb, cph] (jQuery UI library; authors listed in inst/www/shared/jqueryui/AUTHORS.txt), Mark Otto [ctb] (Bootstrap library), Jacob Thornton [ctb] (Bootstrap library), Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Prem Nawaz Khan [ctb] (Bootstrap accessibility plugin), Victor Tsaran [ctb] (Bootstrap accessibility plugin), Dennis Lembree [ctb] (Bootstrap accessibility plugin), Srinivasu Chakravarthula [ctb] (Bootstrap accessibility plugin), Cathy O'Connor [ctb] (Bootstrap accessibility plugin), PayPal, Inc [cph] (Bootstrap accessibility plugin), Stefan Petre [ctb, cph] (Bootstrap-datepicker library), Andrew Rowls [ctb, cph] (Bootstrap-datepicker library), Brian Reavis [ctb, cph] (selectize.js library), Salmen Bejaoui [ctb, cph] (selectize-plugin-a11y library), Denis Ineshin [ctb, cph] (ion.rangeSlider library), Sami Samhuri [ctb, cph] (Javascript strftime library), SpryMedia Limited [ctb, cph] (DataTables library), Ivan Sagalaev [ctb, cph] (highlight.js library), R Core Team [ctb, cph] (tar implementation from R) · rdrr.io
downloadButton: Create a download button or link
View source: R/bootstrap.R
| downloadButton | R Documentation |
Description
Use these functions to create a download button or link; when clicked, it
will initiate a browser download. The filename and contents are specified by
the corresponding downloadHandler() defined in the server
function.
Usage
downloadButton(
outputId,
label = "Download",
class = NULL,
...,
icon = shiny::icon("download"),
enabled = "auto"
)
downloadLink(outputId, label = "Download", class = NULL, ..., enabled = "auto")
Arguments
outputId |
The name of the output slot that the downloadHandler
is assigned to.
|
label |
The label that should appear on the button.
|
class |
Additional CSS classes to apply to the tag, if any.
|
... |
Other arguments to pass to the container tag function.
|
icon |
An icon() to appear on the button. Default is icon("download").
|
enabled |
Controls the enabled/disabled behavior of the button or link.
Defaults to "auto".
-
"auto": the button or link starts disabled and is automatically
enabled once the server has initialized the downloadHandler.
-
TRUE: the button or link starts enabled immediately, without waiting
for the downloadHandler.
-
FALSE: the button or link starts disabled and Shiny will never
automatically enable it, even after the downloadHandler is ready.
You are responsible for managing the enabled/disabled state yourself
(e.g., with shinyjs::enable() and shinyjs::disable()).
|
See Also
downloadHandler()
Examples
## Not run:
ui <- fluidPage(
p("Choose a dataset to download."),
selectInput("dataset", "Dataset", choices = c("mtcars", "airquality")),
downloadButton("downloadData", "Download")
)
server <- function(input, output) {
# The requested dataset
data <- reactive({
get(input$dataset)
})
output$downloadData <- downloadHandler(
filename = function() {
# Use the selected dataset as the suggested file name
paste0(input$dataset, ".csv")
},
content = function(file) {
# Write the dataset to the `file` that will be downloaded
write.csv(data(), file)
}
)
}
shinyApp(ui, server)
## End(Not run)
shiny documentation built on June 21, 2026, 5:07 p.m.
Read the original on rdrr.io ↗