title: Creating navbarMenu and tabPanel using shiny modules
body: <p>I want to create a shiny app that uses <code>navbarMenu()</code> and <code>tabPanel()</code> to display data tables. Instead of writing all of the codes in one <code>app.R</code> file, I plan to use the concept of shiny modules creating <code>R/tabUI.R</code> and <code>R/tabServer.R</code> to generate these tables.
  However, I run into an error and cannot figure it out. Any suggestions and help are appreciated!</p>
  <p><strong>My code:</strong></p>
  <pre><code>### R/tabUI.R
  tabUI &lt;- function(id) {
      tagList(
          navbarMenu(&quot;display table&quot;,
              tabPanel(NS(id, &quot;mtcars table&quot;),
              DT::dataTableOutput(&quot;table&quot;)
          )
      )
   )
  }
  
  
  ### R/tabServer.R
  tabServer &lt;- function(id) {
      moduleServer(id, function(input, output, session){
          output$table &lt;- DT::renderDataTable(mtcars)
      })
  }
  
  
  
  ### app.R
  library(shiny)
  
  ui &lt;- navbarPage(&quot;dashboard&quot;,
      tabUI(&quot;table1&quot;)
  )
  
  server &lt;- function(input, output, session){
      tabServer(&quot;table1&quot;)
  }
  
  shinyApp(ui=ui, server=server)
  
  
  
  </code></pre>
  <p><strong>Error:</strong></p>
  <pre><code>&gt; runApp()
  Error: Navigation containers expect a collection of `bslib::nav()`/`shiny::tabPanel()`s and/or `bslib::nav_menu()`/`shiny::navbarMenu()`s. Consider using `header` or `footer` if you wish to place content above (or below) every panel's contents.
  </code></pre>