rstudio / bslib

Tools for theming Shiny and R Markdown via Bootstrap 3, 4, or 5.
https://rstudio.github.io/bslib/
Other
443 stars 50 forks source link

feat(layout_columns): Use `sm` as the default `col_widths` breakpoint #1014

Closed gadenbuie closed 3 months ago

gadenbuie commented 4 months ago

Fixes two issues with layout_columns():

  1. col_widths = c(12, 6, 6) now becomes col_widths = breakpoints(sm = c(12, 6, 6)) where we previously used md as the default breakpoint. This update aligns with the intuitive expectation that col_widths of a single value is the column widths at all breakpoints (except mobile where we do something completely different).

  2. While here I noticed that we actually do need to include the xs-specific CSS variable when it's not the only variable being set. Without this change the row_heights = breakpoints(xs = ..., sm = ...) doesn't work as expected.

Example app

library(shiny)
# library(bslib)
pkgload::load_all()

ui <- page_fillable(
  layout_columns(
    col_widths = c(12, 6, 6),
    row_heights = breakpoints(
      xs = c(7, 1.5, 1.5),
      sm = c(70, 30)
    ),
    card("Chart 1"),
    navset_card_tab(
      nav_panel("Chart 2"),
      nav_panel("Chart 3")
    ),
    card("Chart 4")
  )
)

server <- function(input, output, session) {

}

shinyApp(ui, server)

Current behavior on shinylive.io.