shiny::downloadButton does not render in flexdashboard

I would like to include a download button in my flexdashboard, however shiny::downloadButton does not render while shiny::downloadLink does:


title: "Sidebar download button"
runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill

library(flexdashboard)

Column {.sidebar}

cars <- data("cars")

# renders

shiny::downloadLink(outputId = "save_link",
                    label = "Save cars.rds")

output$save_link <- downloadHandler(
    filename = function() {"cars.rds"},
    content = function(file) {
      saveRDS(cars, file)
    }
    )

# does not render

shiny::downloadButton(outputId = "save_button",
                    label = "Save cars.rds")

output$save_button <- downloadHandler(
    filename = function() {"cars.rds"},
    content = function(file) {
      saveRDS(cars, file)
    }
    )

Any help would be appreciated

You can write a version which will work in .rmd like this:

downloadButtonRmd <- function (outputId, label = "Download", class = NULL, ...)  {
     tags$a(id = outputId, class = paste("btn btn-default shiny-download-link", 
        class), href = "", target = "_blank", download = NA, 
        icon("download"), label, ...)
 }

For for background, see my stackoverflow answer here: https://stackoverflow.com/questions/42866055/rshiny-download-button-within-rmarkdown/55725085#55725085

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.