valueButton {shinyGizmo}R 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))
    }
  )
}


[Package shinyGizmo version 0.4.2 Index]