Skip to content

Instantly share code, notes, and snippets.

@jrosell
Created November 23, 2021 14:22
Show Gist options
  • Save jrosell/725b3ae3fc1ccaa24ce0a92c466c42c0 to your computer and use it in GitHub Desktop.
Save jrosell/725b3ae3fc1ccaa24ce0a92c466c42c0 to your computer and use it in GitHub Desktop.
library(shiny)
ui <- fluidPage(
titlePanel("Shiny updateInput"),
actionButton(
"input_update",
label = "Utilitzo updateInput",
icon = icon("arrow-up")
),
actionButton(
"click_button",
label = "Actualitzo valor"
)
)
server <- function(input, output, session) {
observeEvent(input$click_button, {
clicks <- input$click_button
icon_status_up <-
is.null(clicks) || clicks %% 2 == 0
icon_name <- if(icon_status_up) {
"arrow-up"
} else {
"arrow-down"
}
updateActionButton(
session,
"input_update",
icon = icon(icon_name)
)
})
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment