Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can shinydashboard use Tabpanels and have a nav bar?

I am currently using shinydashboard but I would like to have different sidbar menues associated with content in the main body. Is this possible with shinydashboard?

For example:

I would like to have something like this https://gallery.shinyapps.io/CDCPlot/

See how when you click on the nav bar options the sidebar menu changes as well as the body.

Is that possible in shinydashboad? I like the look and feel of shinydashboard and would rather not go back to shiny.

THe underlying code is here: https://github.com/NLMichaud/WeeklyCDCPlot/blob/master/ui.R

and uses tabpanels and navbar. Is there something similar in shinydashboard?

Any examples with code?

Thank you!

like image 615
user3022875 Avatar asked Oct 20 '22 02:10

user3022875


1 Answers

What you are asking is tricky and might not be possible because in shinydashboard, top-level navigation controls are located inside the dashboardSidebar (on the left side) and the content is contained inside dashboardBody (on the right side). If you place a navMenu inside dashboardBody, it would have to belong to a specific sidebar item and would disappear if you later click on another sidebar item.

You might need to change the way you want to achieve this. Depending on what you want to do, you might try :

creating a dashboardSidebar with menu items that would normally into the top-menu, and you can place all the controls for that menu under the associated tabItem. You can even make it all dynamic by using renderMenu() in server.R :

output$menu <- renderMenu({
   sidebarMenu(id = "sidebMenu",
       menuItem("Load Data", tabName = "loadData", icon = icon("database"),
          actionButton("press", "Press me")
   )
})

The disadvantage of this is probably that the number of controls you can put inside a sidebar menu is limited while it still looks good. But this is how dashboard is made.

or

using a fullscreen dashboard without sidebar with dashboardSidebar(disable = TRUE) and use a navigation menu in a similar way as in the example you mentioned. You will have no shinydashboard's sidebar and you would have to make your own sidebar just like in your example. This way, you might still enjoy the other features offered by shinydashboard like notifications, boxes, skins, status boxes etc. But this is just a suggestion, it is up to you.

Hope this helps.

like image 131
Servet Avatar answered Oct 30 '22 01:10

Servet