| teal_modules {teal} | R Documentation |
Create teal_module and teal_modules objects
Description
Create a nested tab structure to embed modules in a teal application.
Usage
module(
label = "module",
server = function(id, ...) {
moduleServer(id, function(input, output, session) {
})
},
ui = function(id, ...) {
tags$p(paste0("This module has no UI (id: ", id, " )"))
},
filters,
datanames = "all",
server_args = NULL,
ui_args = NULL
)
modules(..., label = "root")
## S3 method for class 'teal_module'
format(x, indent = 0, ...)
## S3 method for class 'teal_module'
print(x, ...)
## S3 method for class 'teal_modules'
format(x, indent = 0, ...)
## S3 method for class 'teal_modules'
print(x, ...)
Arguments
label |
( |
server |
(
|
ui |
(
|
filters |
( |
datanames |
( |
server_args |
(named |
ui_args |
(named |
... |
|
x |
( |
indent |
( |
Details
module() creates an instance of a teal_module that can be placed in a teal application.
modules() shapes the structure of a the application by organizing teal_module within the navigation panel.
It wraps teal_module and teal_modules objects in a teal_modules object,
which results in a nested structure corresponding to the nested tabs in the final application.
Note that for modules() label comes after ..., so it must be passed as a named argument,
otherwise it will be captured by ....
The labels "global_filters" and "Report previewer" are reserved
because they are used by the mapping argument of teal_slices()
and the report previewer module reporter_previewer_module(), respectively.
Value
module() returns an object of class teal_module.
modules() returns a teal_modules object which contains following fields:
-
label: taken from thelabelargument. -
children: a list containing objects passed in.... List elements are named after theirlabelattribute converted to a validshinyid.
Examples
library(shiny)
module_1 <- module(
label = "a 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")))
},
datanames = "all"
)
module_2 <- 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")))
},
datanames = NULL
)
modules <- modules(
label = "modules",
modules(
label = "nested modules",
module_1
),
module_2
)
app <- init(
data = teal_data(iris = iris),
modules = modules
)
if (interactive()) {
shinyApp(app$ui, app$server)
}