lmglm
lmglm

Reputation: 3

Show a description in Shiny Sidebar

How can I show a description according to the input that was selected in shiny sidebar?

Here is a part of my code:

ui=pageWithSidebar(
  headerPanel("CC"),
  sidebarPanel(
    helpText("Create demographic"),
    selectInput("var", 
                label = "Choose a variable to display",
                choices = c("a", "b",
                            "c", "d"),
                selected = "a")
  ),
  mainPanel(fluidPage(
    ShinyCyJSOutput(outputId = 'cy')
  )
))

When selecting a,b,c or d I want a description to appear.

Upvotes: 0

Views: 59

Answers (1)

starja
starja

Reputation: 10365

You could use conditionalPanels:

library(shiny)

ui <- pageWithSidebar(
  headerPanel("CC"),
  sidebarPanel(
    helpText("Create demographic"),
    selectInput("var", 
                label = "Choose a variable to display",
                choices = c("a", "b",
                            "c", "d"),
                selected = "a"),
    conditionalPanel(condition = "input.var == 'a'",
                     tags$div("Explanation for variable a")),
    conditionalPanel(condition = "input.var == 'b'",
                     tags$div("Explanation for variable b"))
  ),
  mainPanel(fluidPage(
    
  )
)
)

server <- function(input, output, session) {
  
}

shinyApp(ui, server)

Upvotes: 1

Related Questions