Learn R Programming

shinyjs (version 0.1.0)

disabled: Initialize a Shiny input as disabled

Description

Create a Shiny input that is disabled when the Shiny app starts. The input can be enabled later with shinyjs::toggleState or shinyjs::enable.

Usage

disabled(...)

Arguments

...
Shiny input (or tagList or list of of tags that include inputs) to disable.

Value

  • The tag (or tags) that was given as an argument in a disabled state.

See Also

useShinyjs, toggleState, enable, disable

Examples

Run this code
if (interactive()) {
  shiny::shinyApp(
    ui = shiny::fluidPage(
      useShinyjs(),  # Set up shinyjs
      shiny::actionButton("btn", "Click me"),
      disabled(
        shiny::textInput("element", NULL, "I was born disabled")
      )
    ),
    server = function(input, output) {
      shiny::observeEvent(input$btn, {
        enable("element")
      })
    }
  )
}

disabled(shiny::numericInput("num", NULL, 5), shiny::dateInput("date", NULL))

Run the code above in your browser using DataLab