Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/deepanshu88/shinyCopy2clipboard
- Owner: deepanshu88
- Created: 2021-03-16T06:19:19.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-03-19T18:19:37.000Z (over 3 years ago)
- Last Synced: 2024-08-13T07:10:19.529Z (4 months ago)
- Topics: r, rstats, shiny
- Language: R
- Homepage: https://www.listendata.com/2021/03/shinycopy2clipboard-copy-to-clipboard.html
- Size: 32.2 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- jimsghstars - deepanshu88/shinyCopy2clipboard - Copy Text to Clipboard in Shiny Apps (R)
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)```