valueButton: Take value from selected UI element

View source: R/valueButton.R

valueButtonR Documentation

Take value from selected UI element

Description

The components creates button or link that allows to take any value (or attribute) sourced from DOM element existing in Shiny application and pass it to application server.

Usage

valueButton(
  inputId,
  label,
  selector,
  attribute = "value",
  icon = NULL,
  width = NULL,
  try_binding = TRUE,
  ...
)

valueLink(
  inputId,
  label,
  selector,
  attribute = "value",
  icon = NULL,
  try_binding = TRUE,
  ...
)

Arguments

inputId

Id of the button. The value can be accessed in server with 'input[[inputId]]'.

label

Button label.

selector

CSS selector of element the attribute should be taken from. Set '"window"' or '"document"' to access application 'window' or 'document' object.

attribute

Name of the attribute that should be taken from desired element. For nested properties use '.', e.g. 'style.width' or 'navigator.appName'.

icon

Icon included in button.

width

Width of the button.

try_binding

When 'TRUE' and 'selector' points to Shiny Binding and 'attribute == "value"' it tries to convert sourced input value using registered 'inputHandler'.

...

Extra attributes passed to 'button' or 'a' tag.

Value

A 'shiny.tag' class object defining html structure of the button.

Examples

if (interactive()) {
  library(shiny)
  shinyApp(
    ui = fluidPage(
      tags$textarea(id = "txt"),
      valueButton("val", "Take textarea value", "#txt", attribute = "value")
    ),
    server = function(input, output, session) {
      observeEvent(input$val, print(input$val))
    }
  )
}


shinyGizmo documentation built on March 7, 2023, 7:31 p.m.