Shiny/R Wrapper for 'clipboard.js'

Leverages the functionality of 'clipboard.js', a JavaScript library for HMTL5-based copy to clipboard from web pages (see < https://clipboardjs.com> for more information), and provides a reactive copy-to-clipboard UI button component, called 'rclipButton', and a a reactive copy-to-clipboard UI link component, called 'rclipLink', for 'shiny' R applications.


CRAN status Lifecycle: stable

rclipboard: clipboard.js for R/Shiny applications

clipboard.js is a super light javascript framework, which provides copy-to-clipboard functionality using HTML5. The simple rclipboard R package is simple and leverages clipboard.js functionality to provide a reactive copy-to-clipboard UI button component, called rclipButton, and a reactive copy-to-clipboard UI link component, called rclipLink, for Shiny R applications.

While rclipButton and rclipLink will work in applications that use native shiny UI constructors, the code below illustrates a marginally more complex example in which a tooltip is displayed when hovering on top of the button thanks to the use of UI constructors from the bslib package.

library(shiny)
library(bslib)
library(rclipboard)

# The UI
ui <- bslib::page_fluid(
  
  rclipboardSetup(),
  
  # Add a text input
  textInput("copytext", "Copy this:", "Zlika!"),
  
  # UI ouputs for the copy-to-clipboard buttons
  uiOutput("clip"),
  
  # A text input for testing the clipboard content.
  textInput("paste", "Paste here:")
  
)

# The server
server <- function(input, output) {
  
  # Add clipboard buttons
  output$clip <- renderUI({
    rclipButton(
      inputId = "clipbtn",
      label = "rclipButton Copy",
      clipText = input$copytext, 
      icon = icon("clipboard"),
      tooltip = "Click me... I dare you!",
      placement = "top",
      options = list(delay = list(show = 800, hide = 100), trigger = "hover")
    )
  })
  
}

shinyApp(ui = ui, server = server)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("rclipboard")

0.2.1 by Sebastien Bihorel, 3 years ago


https://github.com/sbihorel/rclipboard/


Report a bug at https://github.com/sbihorel/rclipboard/issues/


Browse source code at https://github.com/cran/rclipboard


Authors: Sebastien Bihorel


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports shiny, bslib


Imported by RALSA, aweSOM, filterNHP, pmxcode.

Suggested by GDAtools, SingleCaseES, apa7, grandR, idiogramFISH, journalabbr, scdhlm.


See at CRAN