Skip to contents

Create a copy button that will copy the contents of a target UI element or a provided value to the clipboard.

Usage

copyButton(id, target_id = NULL, text = NULL, cut = FALSE, label = "Copy", ...)

Arguments

id

The inputId for the underlying actionButton.

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().

Value

An actionButton enabled to copy to clipboard.

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)
}