Organize arbitrary Shiny inputs into a grid layout
Usage
organize_inputs(
tag.list,
id = NULL,
title = NULL,
tack = NULL,
columns = NULL,
rows = NULL
)
Arguments
- tag.list
A tagList containing UI inputs or a named list containing multiple tagLists containing UI inputs.
- id
An optional ID for the tabsetPanel if a named list is provided.
- title
An optional title for the grid, should be a UI element, e.g. h3("Title").
- tack
An optional UI input to tack onto the end of the grid.
- columns
Number of columns.
- rows
Number of rows.
Examples
library(dittoVizModules)
# Example 1: Basic usage with a simple grid
ui.inputs <- tagList(
textInput("name", "Name"),
numericInput("age", "Age", value = 30),
selectInput("gender", "Gender", choices = c("Male", "Female", "Other"))
)
#> Error in tagList(textInput("name", "Name"), numericInput("age", "Age", value = 30), selectInput("gender", "Gender", choices = c("Male", "Female", "Other"))): could not find function "tagList"
organize_inputs(ui.inputs, columns = 2, rows = 2)
#> Error in eval(expr, envir, enclos): object 'ui.inputs' not found
# Example 2: Using a named list to create tabs
ui.inputs.tabs <- list(
Personal = tagList(
textInput("firstname", "First Name"),
textInput("lastname", "Last Name")
),
Settings = tagList(
checkboxInput("newsletter", "Subscribe to newsletter", value = TRUE),
sliderInput("volume", "Volume", min = 0, max = 100, value = 50)
)
)
#> Error in tagList(textInput("firstname", "First Name"), textInput("lastname", "Last Name")): could not find function "tagList"
organize_inputs(ui.inputs.tabs)
#> Error in eval(expr, envir, enclos): object 'ui.inputs.tabs' not found
# Example 3: Adding an additional UI element with 'tack'
additional.ui <- actionButton("submit", "Submit")
#> Error in actionButton("submit", "Submit"): could not find function "actionButton"
organize_inputs(ui.inputs, tack = additional.ui, columns = 3)
#> Error in eval(expr, envir, enclos): object 'ui.inputs' not found
# Example 4: Handling a case with more inputs than grid cells
many.inputs <- tagList(replicate(10, textInput("input", "Input")))
#> Error in tagList(replicate(10, textInput("input", "Input"))): could not find function "tagList"
organize_inputs(many.inputs, columns = 3) # Creates more than one row
#> Error in eval(expr, envir, enclos): object 'many.inputs' not found