Skip to contents

[Stable] This function collects a list of teal_modules and teal_module objects and returns a teal_modules object containing the passed objects.

This function dictates what modules are included in a teal application. The internal structure of teal_modules shapes the navigation panel of a teal application.

Usage

modules(..., label = "root")

# S3 method for teal_modules
toString(x, indent = 0, ...)

# S3 method for teal_modules
print(x, ...)

Arguments

...

parameters passed to toString

label

(character(1)) label of modules collection (default "root"). If using the label argument then it must be explicitly named. For example modules("lab", ...) should be converted to modules(label = "lab", ...)

x

teal_modules

indent

(integer) indent level; each submodule is indented one level more

Value

object of class teal_modules. Object contains following fields

  • label: taken from the label argument

  • children: a list containing objects passed in .... List elements are named after their label attribute converted to a valid shiny id.

(character)

Examples

library(shiny)

app <- init(
  data = teal_data(dataset("iris", iris)),
  modules = modules(
    label = "Modules",
    modules(
      label = "Module",
      module(
        label = "Inner module",
        server = function(id, data) {
          moduleServer(
            id,
            module = function(input, output, session) {
              output$data <- renderDataTable(data[["iris"]]())
            }
          )
        },
        ui = function(id) {
          ns <- NS(id)
          tagList(dataTableOutput(ns("data")))
        },
        filters = "all"
      )
    ),
    module(
      label = "Another module",
      server = function(id) {
        moduleServer(
          id,
          module = function(input, output, session) {
            output$text <- renderText("Another module")
          }
        )
      },
      ui = function(id) {
        ns <- NS(id)
        tagList(textOutput(ns("text")))
      },
      filters = NULL
    )
  )
)
if (FALSE) {
runApp(app)
}