updateTextInputIcon {shinyWidgets} | R Documentation |
Change the value of a text input icon on the client
updateTextInputIcon(
session,
inputId,
label = NULL,
value = NULL,
placeholder = NULL,
icon = NULL
)
session |
The |
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. |
placeholder |
The placeholder to set for the input object. |
icon |
Icon to update, note that you can update icon only
if initialized in |
No value.
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)