The R Shiny website has a great example of how to update the labels and values of a variety of input types based on user input. However, I couldn't find anything for buttons. Specifically, how do I update the label for a button based on user input?
You can dynamically create the Button like so, updating the labels at the same time:
library(shiny)
ui =(pageWithSidebar(
headerPanel("Test Shiny App"),
sidebarPanel(
textInput("sample_text", "test", value = "0"),
#display dynamic UI
uiOutput("my_button")),
mainPanel()
))
server = function(input, output, session){
#make dynamic button
output$my_button <- renderUI({
actionButton("action", label = input$sample_text)
})
}
runApp(list(ui = ui, server = server))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With