modularUI: Assemble UI content from files into Shiny Layout

Description Usage Arguments Value Examples

View source: R/modularUI.R

Description

Compiles all Module UI files into the desired layout.fun using do.call(), keeping your app.R file tidy. This can be run within ui.R, shinyUI(), or renderUI(), just like any other Shiny UI element.

Usage

1
modularUI(module.dir, module.file, numbered = FALSE, layout.fun, ...)

Arguments

module.dir

Path to directory that contains modules (child directories)

module.file

Name of file found within module directories that contains UI code

numbered

If TRUE, directories will be ordered by numeric prefix (e.g., 01_Index, 02_About)

layout.fun

Any Shiny UI function that leverages tabPanel() elements (navbarPage(), navlistPanel(), tabsetPanel(), etc)

...

Additional arguments to be passed to the supplied layout.fun

Value

A Shiny UI object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# app.R
# Create a UI object and render it
## Not run: 
server <- function(input, output, session) {
  output$appUI <- renderUI({
    modularUI(
      module.dir = file.path('.', 'modules'),
      module.file = 'ui.R',
      layout.fun = navbarPage,
      title = 'My Modular App'
    )
  })
}
ui <- uiOutput('appUI')
shinyApp(ui, server)

## End(Not run)

ndrewGele/polish documentation built on March 9, 2021, 6:34 p.m.