Learn R Programming

shinyWidgets (version 0.5.4)

updateNumericInputIcon: Change the value of a numeric input icon on the client

Description

Change the value of a numeric input icon on the client

Usage

updateNumericInputIcon(
  session,
  inputId,
  label = NULL,
  value = NULL,
  min = NULL,
  max = NULL,
  step = NULL,
  icon = NULL
)

Arguments

session

The session object passed to function given to shinyServer.

inputId

The id of the input object.

label

The label to set for the input object.

value

The value to set for the input object.

min

Minimum value.

max

Maximum value.

step

Step size.

icon

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

Value

No value.

Examples

Run this code
# NOT RUN {
library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  numericInputIcon(
    inputId = "id",
    label = "With an icon",
    value = 10,
    icon = icon("percent")
  ),
  actionButton("updateValue", "Update value"),
  actionButton("updateIcon", "Update icon"),
  verbatimTextOutput("value")
)

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

  output$value <- renderPrint(input$id)

  observeEvent(input$updateValue, {
    updateNumericInputIcon(
      session = session,
      inputId = "id",
      value = sample.int(100, 1)
    )
  })

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

}

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

Run the code above in your browser using DataLab