How to update button labels in R Shiny?

后端 未结 4 1893
独厮守ぢ
独厮守ぢ 2021-01-20 00:10

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 butto

4条回答
  •  终归单人心
    2021-01-20 01:04

    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))
    

提交回复
热议问题