Can you elaborate on how specifically this could/should work? Regardless, it probably won't be very straightforward to do this via a tooltip. It would be easiest (and most accessible) to do this via an actual button:
library(shiny)
ui <- fluidPage(
downloadButton("download"),
plotlyOutput("p")
)
server <- function(input, output, session) {
data <- reactive(mtcars)
output$p <- renderPlotly({
plot_ly(data(), x = ~wt, y = ~mpg)
})
output$download <- downloadHandler(
filename = "data.csv",
content = function(file) {
readr::write_csv(data(), file)
}
)
}
shinyApp(ui, server)
Another option would be to add a custom download icon in plotly's modebar, but again, it won't be super straightforward and will require some JavaScript+SVG knowledge -- https://plotly-r.com/control-modebar.html