R Shiny navbarMenu

后端 未结 1 614
盖世英雄少女心
盖世英雄少女心 2020-12-14 11:59

I\'m developing a Shiny app using the development version of the package, as documented here.

When I use navbarPage with tabsetPanel, every

相关标签:
1条回答
  • 2020-12-14 12:46

    I wish I could find a good analogy or were a better writer to explain this in few words.

    But I think of it in terms of containers and content. In your fist example you have a "navbar page". That is a container that can be filled with other "pages" such as tabPanels.

    But tabPanels cannot be filled with tabPanels, only with content like graphs or tables that your R output is generating. If you want a page with multiple tabPanels you need a container that is able to contain them: a tabsetPanel (literally a set of tabpanels).

    shinyUI(
        navbarPage("Page Title",
            tabPanel("Panel 1",
                tabsetPanel(
                  tabPanel("Panel 1.1"),
                  tabPanel("Panel 1.2")
                )),
            tabPanel("Panel 2"),
            tabPanel("Panel 3")
            )
    )
    

    now you will see that you have an extra "page" set by the tabsetPanel (a set of tabs) with its own tabs.

    enter image description here

    You can try to follow that analogy through with other examples on the shiny app layout guide that you link to. So for instance, in your example you will never be able to make a submenu but just adding another tabPanel to a tabPanel (a tabPanel cannot be a container for a tabPanel as we saw above). You would first need to say that you want a navbarMenu, which in fact can contain multiple tabPanels.

    It seems complex because navigation and pages are very closely related, and if a container contains containers, it becomes in practice a navigation item. There are good hints in the terms that the RStudio team chose for these lay-out items, but it is not always immediately obvious how it works.

    0 讨论(0)
提交回复
热议问题