Skip to contents

Enable a predefined button or link to interact with the clipboard.

Usage

withCopy(x, target_id = NULL, text = NULL, cut = FALSE)

Arguments

x

actionButton or actionLink.

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.

Value

Updated button or link.

Examples

if (interactive()) {
  ui <- fluidPage(
    textOutput("test_text"),

    # Copy other output
    withCopy(actionLink("copyb1",   "Copy", icon = icon("clipboard")), target_id = "test_text"),
    withCopy(actionButton("copyb2", "Copy", icon = icon("clipboard")), text = "copy copy me"),
  )

  server <- function(input, output, session) {
    output$test_text <- renderText("The text we are to copy!")
  }

  shinyApp(ui, server)
}