# 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