I am trying to add an actionButton which will copy a text. I am using rclipButton fuction but the button alignment and the copied value are not coming correctly.
library(shiny)
library(rclipboard)
app <- shinyApp(
ui = fluidPage(
DT::dataTableOutput("mydatatable")
),
server = shinyServer(function(input, output, session) {
mycars <- reactive({ head(mtcars)})
output$mydatatable = DT::renderDataTable(mycars(), selection = 'single',
rownames = FALSE, options = list(dom = 't'))
selected_row <- reactiveVal(value = NULL)
observeEvent(input$mydatatable_rows_selected,{
selected_row(input$mydatatable_rows_selected)
})
observeEvent(selected_row(), {
showModal( modalDialog(
title = "Selected a row!",
fluidRow(
column(3, tags$p(strong("mpg : "), mycars()$mpg[selected_row()])),
column(2, rclipButton("copy", label = "", clipText = as.character(mycars()[selected_row(), 'mpg']), icon = icon("clipboard"), modal = TRUE, width = "30px")),
column(12, tags$p(strong("cyl : "), mycars()$cyl[selected_row()]))
)
))
})
})
)
app
I wanted to have a copy icon just next to the mpg value and the mpg valued will get copied by clicking the icon.

How is it possible using rclipButton or any other function?