hide/ show more than one input elements in UI section in the shiny app

In the UI part of shiny, I have some radio buttons, input boxes, and...
how can I show/ hide some of them together, for example, see this below code, I would like by selecting "cell type", these fields appear "select desire TF", select 1st cell type", "select 2nd cell type", and "select one condition" and the other ones disappear.
I tried to show, and hide by defining "id" for mentioned elements, but it didn't work. please see the attached image and


the code:
</>

  tabPanel("Differential Analysis",
           sidebarLayout(
             sidebarPanel(
               tags$h5("Mode"),
               #Mode Section
               radioButtons("mode_choice", "Choose one Mode:",
                            choices = c("Cell Type" = "celltype",
                                        "Condition" = "condition"),
                            inline = T
               ),
               tags$hr(),
               selectizeInput("TF_query1",
                              "Select Desire TF:",
                              c( "ALL", 
                                TF_vector),
               )
               ,
               fluidRow(
                 
               #if user selects condition, he will see two lists to select condition1 VS condition2 
              column(6,selectizeInput("condition1",
                                    label = "Select 1st Condition",
                                    choices = c("R1"),
                                    multiple = F)) ,
               column(6,selectizeInput("condition2",
                              label = "Select 2nd Condition",
                              choices = c("R2"),
                              multiple = F)),
               ),
              
              fluidRow(
                
               #if user selects Cell type, he will see two lists to select celltype1 VS celltype2 
              column(6, selectizeInput("celltype1",
                              label = "Select 1st Cell Type",
                              choices = c("CM1"),
                              multiple = F)),
               column(6, selectizeInput("celltype2",
                              label = "Select 2nd Cell Type",
                              choices = c("CM1"),
                              multiple = F)),
              ),
              tags$hr(),
               #!Mode Section (opposite of first selection)
               selectizeInput("general_celltype",
                              label = "Select one Cell Type:",
                              choices = c("CM1"),
                              multiple = F),
               selectizeInput("general_condition",
                              label = "Select one Condition:",
                              choices = c("Random1"),
                              multiple = F),

             ),

</>

Is there anybody who knows the answer to this question?
Thanks in advance.

Hi, can you use a conditional panel?

https://shiny.rstudio.com/reference/shiny/1.6.0/conditionalPanel.html

2 Likes

Thanks @williaml
It worked :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.