Create a copy button that will copy the contents of a target UI element or a provided value to the clipboard.
Arguments
- id
The
inputId
for the underlyingactionButton
.- target_id
The id of the UI output to copy.
- text
Value to copy to the clipboard when the button is clicked.
- cut
Cut text to clipboard.
- label
Label of the button.
- ...
Other arguments passed to
shiny::actionButton()
.
Details
To update the value that will be copied from the server see
updateCopyText()
.
Examples
if (interactive()) {
ui <- fluidPage(
textOutput("test_text"),
# Copy other output
copyButton("cp1", target_id = "test_text", icon = icon("clipboard")),
# Copy a set value
copyButton("cp2", text = "This is the text you want!", label = "Copy Text")
)
server <- function(input, output, session) {
output$test_text <- renderText("The text we are to copy!")
}
shinyApp(ui, server)
}