Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

updateTextInputIcon

Change the value of a text input icon on the client


Description

Change the value of a text input icon on the client

Usage

updateTextInputIcon(
  session,
  inputId,
  label = NULL,
  value = NULL,
  placeholder = NULL,
  icon = NULL
)

Arguments

session

The session object passed to function given to shinyServer. Default is getDefaultReactiveDomain().

inputId

The id of the input object.

label

The label to set for the input object.

value

Initial value.

placeholder

A character string giving the user a hint as to what can be entered into the control. Internet Explorer 8 and 9 do not support this option.

icon

Icon to update, note that you can update icon only if initialized in textInputIcon.

Value

No value.

Examples

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  textInputIcon(
    inputId = "id",
    label = "With an icon",
    icon = icon("user-circle-o")
  ),
  actionButton("updateValue", "Update value"),
  actionButton("updateIcon", "Update icon"),
  verbatimTextOutput("value")
)

server <- function(input, output, session) {

  output$value <- renderPrint(input$id)

  observeEvent(input$updateValue, {
    updateTextInputIcon(
      session = session,
      inputId = "id",
      value = paste(sample(letters, 8), collapse = "")
    )
  })

  observeEvent(input$updateIcon, {
    i <- sample(c("home", "gears", "dollar", "globe", "sliders"), 1)
    updateTextInputIcon(
      session = session,
      inputId = "id",
      icon = icon(i)
    )
  })

}

if (interactive())
  shinyApp(ui, server)

shinyWidgets

Custom Inputs Widgets for Shiny

v0.6.0
GPL-3
Authors
Victor Perrier [aut, cre, cph], Fanny Meyer [aut], David Granjon [aut], Ian Fellows [ctb] (Methods for mutating vertical tabs & updateMultiInput), Wil Davis [ctb] (numericRangeInput function), Spencer Matthews [ctb] (autoNumeric methods), JavaScript and CSS libraries authors [ctb, cph] (All authors are listed in LICENSE.md)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.