shiny: passing reactiveValues to conditionalPanel

As @jdharrison pointed out, you have the problem, that you have reactive values or any other data on the server side and the conditional panel is a JS condition + some HTML on the client side. Hence, if you want to dynamically update the JS condition according to some value you calculated on the server side, you need to get the data from the server to the client. I think what you could do is use an still undocumented feature of shiny to pass custom data from the server to the client. I wrote a blog post on how to do that:

I guess you could use that approach to dynamically update the JS panel condition. You would need to write a JS function that does this after the data has been passed. So this boils down to replacing the data-display-if attribute of the conditionalPanel output with the values you want.

Another idea: If your UI strongly depends on calculations on the server side you may want to consider creating the (sidebar) content dynamically using renderUI.

EDIT: Btw, that's what @jdharrison referred to in his second comment.

You can also do it by rendering text.


    # Application title

        actionButton("ShowCond", "Show Conditional Panel"),
          condition = "output.test=='5'",
          actionButton("CheckFile", "Check file")


shinyServer(function(input, output, session) {
  var <- eventReactive(input$ShowCond, {

  output$test <- renderText({

The catch is here that it doesn't work without the verbatimTextOutput. You need to include it somewhere on your UI side. However, you could reuse it as a message.


It is also possible without the verbatimtext. By default Shiny suspends all output when they are not displayed. However, this can be changed by setting the following option for a specific output variable:

outputOptions(output, "test", suspendWhenHidden=FALSE)

In this case, there is no more need to use verbatimtext (and the corresponding rendertext).