Skip to content
RDocumentation: colourInput
  • AI Chat
  • Code
  • Report
  • Note that this notebook was automatically generated from an RDocumentation page. It depends on the package and the example code whether this code will run without errors. You may need to edit the code to make things work.

    if(!require('shinyjs')) {
        install.packages('shinyjs')
        library('shinyjs')
    }
    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)
        }
      )
    }