Creates a panel that is visible or not, depending on the value of a JavaScript expression. The JS expression is evaluated once at startup and whenever Shiny detects a relevant change in input/output.

conditionalPanel(condition, ..., ns = NS(NULL))



A JavaScript expression that will be evaluated repeatedly to determine whether the panel should be displayed.


Elements to include in the panel.


The namespace() object of the current module, if any.


In the JS expression, you can refer to input and output JavaScript objects that contain the current values of input and output. For example, if you have an input with an id of foo, then you can use to read its value. (Be sure not to modify the input/output objects, as this may cause unpredictable behavior.)


You are not recommended to use special JavaScript characters such as a period . in the input id's, but if you do use them anyway, for example, inputId = "", you will have to use input[""] instead of to read the input value.


## Only run this example in interactive R sessions
if (interactive()) {
  ui <- fluidPage(
      selectInput("plotType", "Plot Type",
        c(Scatter = "scatter", Histogram = "hist")
      # Only show this panel if the plot type is a histogram
        condition = "input.plotType == 'hist'",
          "breaks", "Breaks",
          c("Sturges", "Scott", "Freedman-Diaconis", "[Custom]" = "custom")
        # Only show this panel if Custom is selected
          condition = "input.breaks == 'custom'",
          sliderInput("breakCount", "Break Count", min = 1, max = 50, value = 10)

  server <- function(input, output) {
    x <- rnorm(100)
    y <- rnorm(100)

    output$plot <- renderPlot({
      if (input$plotType == "scatter") {
        plot(x, y)
      } else {
        breaks <- input$breaks
        if (breaks == "custom") {
          breaks <- input$breakCount

        hist(x, breaks = breaks)

  shinyApp(ui, server)