if (interactive()) {
shiny::shinyApp(
ui = shiny::fluidPage(
shiny::div("Selected colour:",
shiny::textOutput("value", inline = TRUE)),
colourInput("col", "Choose colour", "red"),
shiny::h3("Update colour input"),
shiny::textInput("text", "New colour: (colour name or HEX value)"),
shiny::selectInput("showColour", "Show colour",
c("both", "text", "background")),
shiny::checkboxInput("allowTransparent", "Allow transparent", FALSE),
shiny::actionButton("btn", "Update")
),
server = function(input, output, session) {
shiny::observeEvent(input$btn, {
updateColourInput(session, "col",
value = input$text, showColour = input$showColour,
allowTransparent = input$allowTransparent)
})
output$value <- shiny::renderText(input$col)
}
)
}
Run the code above in your browser using DataLab