Conditional tabBox with shinydashboard

Hello all,

I am using shinydashboard and I am trying to condition the tabs on the tabBox function based on the user choices (for example if the user select option 1 then open tab1, tab2 and tab4 otherwise open tab3 and tab4). I tried to use the conditionalPanel function however it shift the tab outside the tabBox. Any suggestion how to do it?

Thank you in advance!
Rami

It's not an elegant solution, but could you put each tab inside conditionalPanel()? Something like:

tabBox(
    conditionalPanel([some condition], tabPanel([content of tab])),
    conditionalPanel([some other condition], tabPanel([content of tab]))
)

Alternatively if you just want to have a different tab selected each time a user changes an option (rather than hiding/showing the tabs completely) then it might be worth looking at updateTabsetPanel().

1 Like

Another way could be to create the tabs on the fly using insertTab() or appendTab(): https://shiny.rstudio.com/reference/shiny/latest/insertTab.html . Here's an example of using appendTab() when the user clicks on an Airport row in the lower right plot: https://edgarruiz.shinyapps.io/flights-dashboard/ and here's the Gist for it: https://gist.github.com/edgararuiz/876ba4718e56af66c3e1181482b6cb99

3 Likes

Thank you for the answers!