The standard element for placing elements on the grid in a simple card container

grid_card(area, ...)

Arguments

area

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

...

Arguments passed on to bslib::card

full_screen

If TRUE, an icon will appear when hovering over the card body. Clicking the icon expands the card to fit viewport size.

height

Any valid CSS unit (e.g., height="200px"). Doesn't apply when a card is made full_screen (in this case, consider setting a height in card_body()).

max_height,min_height

Any valid CSS unit (e.g., max_height="200px"). Doesn't apply when a card is made full_screen (in this case, consider setting a max_height in card_body()).

fill

Whether or not to allow the card to grow/shrink to fit a fillable container with an opinionated height (e.g., page_fillable()).

class

Additional CSS classes for the returned UI element.

wrapper

A function (which returns a UI element) to call on unnamed arguments in ... which are not already card item(s) (like card_header(), card_body(), etc.). Note that non-card items are grouped together into one wrapper call (e.g. given card("a", "b", card_body("c"), "d"), wrapper would be called twice, once with "a" and "b" and once with "d").

See also

bslib::card for underlying function. bslib::card_header, bslib::card_body, bslib::card_footer. grid_card_text() for a card with just text content, grid_card_plot() for a card with just plot content, grid_place() to place any tag onto the grid without needing to wrap in a card, and card_plot_output() for including a smart-sized plot within a card.

Examples

if (FALSE) {
library(gridlayout)
library(shiny)
library(bslib)

shinyApp(
  ui = grid_page(
    layout = c(
      "header  header",
      "sidebar distPlot"
    ),
    row_sizes = c("50px", "1fr"),
    col_sizes = c("200px", "1fr"),
    grid_card_text("header", "This is my header"),
    grid_card(
      area = "sidebar",
      card_header("Settings"),
      card_body(
        sliderInput("bins", "Number of bins:", 1, 50, 30, width = "100%")
      )
    ),
    grid_card_plot("distPlot")
  ),
  server = function(input, output) {
    output$distPlot <- renderPlot({
      x    <- faithful[, 2]
      bins <- seq(min(x), max(x), length.out = input$bins + 1)
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
  }
)
}