Creates a panel for a layout with its own internal gridlayout

grid_nested(area, layout, ..., id = NULL, title = NULL, flag_mismatches = TRUE)

Arguments

area

Name of grid area, should match an area defined in the layout section of the wrapping grid_page() or grid_container().

layout

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

ID unique to this container (note that the HTML will be prefixed with grid- to avoid namespace clashes)

title

Optional title for the card. Gets wrapped in bslib::card_header()

flag_mismatches

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.

Value

A grid_card with a nested layout within it

See also

grid_card, grid_container

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.

Examples

# 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)
}