gridlayout
positioned contentgrid_nested.Rd
Creates a panel for a layout with its own internal gridlayout
grid_nested(area, layout, ..., id = NULL, title = NULL, flag_mismatches = TRUE)
Name of grid area, should match an area defined in the layout
section of the wrapping grid_page()
or grid_container()
.
Either a markdown table representation (see
md_to_gridlayout
) or a gridlayout
object defining the
desired layout for your Shiny app.
grid_card()
(or similar) arguments that will fill the grid
layout. Note the areas should match the those provided in layout
.
ID unique to this container (note that the HTML will be prefixed
with grid-
to avoid namespace clashes)
Optional title for the card. Gets wrapped in
bslib::card_header()
Should a mismatch between supplied elements
ui
definitions and layout trigger a warning? In advanced cases you may want to
dynamically set your layout and sometimes omit panels.
A grid_card
with a nested layout within it
grid_page()
for using a gridlayout to entirely define the page.
grid_container()
for placing a gridlayout in non-gridlayout parent
elements. grid_card()
for placing content inside your layout. See
vignette("defining-a-layout", package = "gridlayout")
for more info on
defining your layout.
# Demonstrating the ability to nest grid layouts within other gridlayouts
library(gridlayout)
library(shiny)
library(bslib)
#>
#> Attaching package: ‘bslib’
#> The following object is masked from ‘package:utils’:
#>
#> page
ui <- grid_page(
layout = c(
"header header",
"sidebar plots"
),
row_sizes = c("50px", "1fr"),
col_sizes = c("250px", "1fr"),
grid_card_text("header", "This is my header"),
grid_card(
"sidebar",
card_header("Settings"),
sliderInput("bins","Number of bins:", 1, 50, 30, width = "100%")
),
grid_nested(
"plots",
title = "Plots - in technicolor",
layout = c(
"distPlot distPlot distPlot",
"redPlot bluePlot greenPlot"
),
grid_card_plot("distPlot"),
grid_card_plot("redPlot"),
grid_card_plot("bluePlot"),
grid_card_plot("greenPlot")
)
)
drawHist <- function(nbins, color) {
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = nbins + 1)
hist(x, breaks = bins, col = color, border = "white")
}
server <- function(input, output) {
output$distPlot <- renderPlot(drawHist(input$bins, "darkgray"))
output$redPlot <- renderPlot(drawHist(input$bins, "orangered"))
output$bluePlot <- renderPlot(drawHist(input$bins, "steelblue"))
output$greenPlot <- renderPlot(drawHist(input$bins, "forestgreen"))
}
if(FALSE){
shinyApp(ui, server)
}