deactivateItems: Switch inputs on and off

View source: R/server.R

deactivateItemsR Documentation

Switch inputs on and off

Description

Greys out inputs so they can't be used, or makes them usable again. Use this in the server to stop users clicking a button or download before the app is ready for it, for example deactivating every download at start and activating each one once there is something to download.

Usage

deactivateItems(itemIDs)

activateItems(itemIDs)

Arguments

itemIDs

IDs of the inputs to switch, as a character vector.

Details

Needs shinyjs::useShinyjs() in the UI, which UINav() adds for you.

Value

NULL, invisibly. Called for its effect on the page.

Examples

if (interactive()) {
  shiny::shinyApp(
    ui = UINav(
      appName = "Demo",
      singleTab("Home",
        navCheckbox("ready", "Ready to download?"),
        navDownload("theDownload", "Download")
      )
    ),
    server = function(input, output, session) {
      shiny::observe({
        if (isTRUE(input$ready)) {
          activateItems("theDownload")
        } else {
          deactivateItems("theDownload")
        }
      })
    }
  )
}

EZRShiny documentation built on Oct. 10, 2026, 5:08 p.m.