dreamRs / fresh

Fresh shiny themes
https://dreamrs.github.io/fresh/
GNU General Public License v3.0
224 stars 10 forks source link

Error when specifying a column width >12 #7

Closed MaxKerney closed 3 years ago

MaxKerney commented 3 years ago

Although the grid_columns argument to bs_vars_global() makes it possible to increase the number of grid columns that are used, it seems that Shiny still prevents you from specifying any one column with a width greater than 12:

if (interactive()) {
  library(shiny)

  ui <- fluidPage(
    use_theme(
      create_theme(
        theme = "default",
        bs_vars_global(
          body_bg = "#F5A9E1",
          text_color = "#FFF",
          grid_columns = 16
        ),
        output_file = NULL
      )
    ),
    tags$h1("My custom app!"),
    tags$h3("With plenty of columns!"),
    fluidRow(
      column(
        width = 15, "Column 1"
      ),
      column(
        width = 1, "Column 2"
      )
    )
  )

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

  }

  shinyApp(ui, server)
}
Error in column(width = 15, "Column 1") : 
  column width must be between 1 and 12 
pvictor commented 3 years ago

Hello,

Sorry for late answer. That a limitation of shiny::column, you have to use HTML tags directly or rewrite column(), e.g. :

tags$div(
  class = "col-sm-15",
  ...
)
 # or
column <- function (width, ..., offset = 0) {
  if (!is.numeric(width) || (width < 1)) 
    stop("column width must be between 1 and 12")
  colClass <- paste0("col-sm-", width)
  if (offset > 0) {
    colClass <- paste0(colClass, " offset-md-", offset, 
                       " col-sm-offset-", offset)
  }
  htmltools::div(class = colClass, ...)
}