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
if (FALSE) { # interactive()
library(VizModules)
# 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"))
)
organize_inputs(ui.inputs, columns = 2, rows = 2)
# 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)
)
)
organize_inputs(ui.inputs.tabs, columns = 1)
# Example 3: Adding an additional UI element with 'tack'
additional.ui <- actionButton("submit", "Submit")
organize_inputs(ui.inputs, tack = additional.ui, columns = 3)
# Example 4: Handling a case with more inputs than grid cells
many.inputs <- tagList(replicate(10, textInput("input", "Input")))
organize_inputs(many.inputs, columns = 3) # Creates more than one row
}