CopyButton: Button for copying text to clipboard

Description Usage Arguments Value Author(s) Examples

View source: R/copy.R

Description

It copies text to clipboard using clipboardjs

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
CopyButton(
  id,
  label,
  text = "No Text",
  icon = NULL,
  width = NULL,
  class = NULL,
  modal = FALSE,
  ...
)

Arguments

id

HTML ID to use for button.

label

Text label of the button.

text

Text to be copied in clipboard.

icon

icon to be shown on the button before label.

width

width of the button.

class

CSS class for customizing button.

modal

Whether button is used within bootstrap modal.

Value

Button

Author(s)

Deepanshu Bhalla

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
if (interactive()) {
 ui <- fluidPage(

  # Setup
  use_copy(),

  # Text Input 1
  textInput("text", "Enter Your Text"),

  # Copy Button 1
  CopyButton(
    "copybtn",
    "Copy to Clipboard",
    icon = icon("copy"),
    text = "No Text Found",
    class = "btn-primary",
    width = "150px"
  )

)
server <- function(input, output, session) {

  observe({

    req(input$copybtn)
    CopyButtonUpdate(session,
                     id = "copybtn",
                     label = "Copy to Clipboard",
                     icon = icon("copy"),
                     text = input$text
    )

  })

}

shinyApp(ui = ui, server = server)
}

deepanshu88/shinyCopy2clipboard documentation built on Dec. 19, 2021, 10:08 p.m.