Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/deepanshu88/shinyCopy2clipboard

Copy Text to Clipboard in Shiny Apps
https://github.com/deepanshu88/shinyCopy2clipboard

r rstats shiny

Last synced: 9 days ago
JSON representation

Copy Text to Clipboard in Shiny Apps

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# shinyCopy2clipboard: Copy Text to Clipboard in shiny apps

### Introduction
In this package we use [clipboard.js](https://clipboardjs.com/) which is a lightweight (3kb) javascript library to copy text to clipboard. Tooltip is also added separately in this package which is outside the scope of this javascript library. With this package you can fetch the value from shiny app on the client and send it to clipboard

## Installation

You can install the released version of shinyCopy2clipboard from [GitHub](https://github.com/) with:

``` r
# install.packages("remotes")
remotes::install_github("deepanshu88/listendata")
```

## Example

This is a basic example which shows you how to solve a common problem:

```{r example}
library(shiny)
library(shinyCopy2clipboard)

# UI
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
server <- function(input, output, session) {

observe({

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

})

}

# Run App
shinyApp(ui = ui, server = server)

```