You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So glad you're finding the toolbar_*options useful! We've been prioritizing inputs to bring over to toolbar styling, so knowing that a toolbar_download_button() would be useful is really helpful, I'll bump it up the list to get in there soon.
In the meantime, you can get most of the way there dropping in some toolbar classes and a little bit of styling. You unfortunately don't get the nice tooltip this way, but you can get the aria with aria-label and title (though you could probably get away with one or the other):
# Using a Download Button as a Toolbar Button
library(shiny)
library(bslib)
ui <- page_fluid(
card(
card_header(
"Sales Data",
toolbar(
align = "right",
# Download button styled to match toolbar buttons
downloadButton(
"download_data",
label = "",
icon = icon("download"),
class = "bslib-toolbar-input-button btn-sm border-0", # Gets you most of the toolbar styling
`data-type` = "icon", # Makes sure the right rules apply for an icon-only button
title = "Download data", # Extra labeling for screenreaders since we're pulling label
`aria-label` = "Download data", # Additional labeling for screenreaders
style = paste(
"padding: 0;",
"display: flex;",
"align-items: center;",
"justify-content: center;"
)
)
)
),
card_body(
tableOutput("data_table")
)
)
)
server <- function(input, output, session) {
output$data_table <- renderTable({
head(mtcars, 10)
})
output$download_data <- downloadHandler(
filename = function() {
paste("data-", Sys.Date(), ".csv", sep = "")
},
content = function(file) {
write.csv(mtcars, file, row.names = FALSE)
}
)
}
shinyApp(ui, server)
Activity
elnelson575 commentedon Mar 13, 2026
So glad you're finding the
toolbar_*options useful! We've been prioritizing inputs to bring over to toolbar styling, so knowing that atoolbar_download_button()would be useful is really helpful, I'll bump it up the list to get in there soon.In the meantime, you can get most of the way there dropping in some toolbar classes and a little bit of styling. You unfortunately don't get the nice tooltip this way, but you can get the aria with
aria-labelandtitle(though you could probably get away with one or the other):Add design spec for toolbar_download_button()
Add design spec for toolbar_download_button()