I'm trying to write a simple shiny app with an actionButton
. When the actionButton
is pressed, some text output should be printed directly below. The code below takes me part way to a solution:
shinyApp(
ui = shinyUI( fluidPage(
actionButton("button", "don't press the button"),
verbatimTextOutput("text")
)
),
server = function(input, output, session){
observeEvent(input$button, {
output$text <- renderText({"ahh you pressed it"})
})
}
)
There are two things I'd like to change, but not sure how:
1) The code above shows an empty gray box before the button is pressed - I'd like there to be nothing there prior to the button being pressed. It looks like conditionalPanel
might be the right approach, but not sure how to implement this.
2) Can the above code be adapted so that once the button is pressed a second time, the text output is hidden again?