Search code examples
rshinybslib

bslib card's `full_screen` feature is not working within shiny but works within markdown


library(shiny)
library(bslib)
#> 
#> Attaching package: 'bslib'
#> The following object is masked from 'package:utils':
#> 
#>     page

ui <-  fluidPage(
  
  bslib::card(full_screen = T,
              bslib::card_header("Full screen is not working within shiny but works as html only"))
)

server <- function(input, output) { }
shinyApp(ui, server)
#> PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.

Created on 2023-04-12 with reprex v2.0.2

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.2.3 (2023-03-15)
#>  os       Ubuntu 22.04.2 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Europe/Istanbul
#>  date     2023-04-12
#>  pandoc   2.19.2 @ /usr/lib/rstudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version date (UTC) lib source
#>  P bslib       * 0.4.2   2022-12-16 [?] RSPM (R 4.2.0)
#>  P cachem        1.0.7   2023-02-24 [?] RSPM (R 4.2.0)
#>  P cli           3.6.1   2023-03-23 [?] CRAN (R 4.2.3)
#>  P digest        0.6.31  2022-12-11 [?] CRAN (R 4.2.3)
#>  P ellipsis      0.3.2   2021-04-29 [?] CRAN (R 4.2.3)
#>  P evaluate      0.20    2023-01-17 [?] CRAN (R 4.2.3)
#>  P fastmap       1.1.1   2023-02-24 [?] CRAN (R 4.2.3)
#>  P fs            1.6.1   2023-02-06 [?] CRAN (R 4.2.3)
#>  P glue          1.6.2   2022-02-24 [?] CRAN (R 4.2.3)
#>  P htmltools     0.5.5   2023-03-23 [?] CRAN (R 4.2.3)
#>  P httpuv        1.6.9   2023-02-14 [?] RSPM (R 4.2.0)
#>  P jquerylib     0.1.4   2021-04-26 [?] RSPM (R 4.2.0)
#>  P jsonlite      1.8.4   2022-12-06 [?] CRAN (R 4.2.3)
#>  P knitr         1.42    2023-01-25 [?] CRAN (R 4.2.3)
#>  P later         1.3.0   2021-08-18 [?] CRAN (R 4.2.3)
#>  P lifecycle     1.0.3   2022-10-07 [?] CRAN (R 4.2.3)
#>  P magrittr      2.0.3   2022-03-30 [?] CRAN (R 4.2.3)
#>  P mime          0.12    2021-09-28 [?] RSPM (R 4.2.0)
#>  P promises      1.2.0.1 2021-02-11 [?] CRAN (R 4.2.3)
#>  P purrr         1.0.1   2023-01-10 [?] CRAN (R 4.2.3)
#>  P R.cache       0.16.0  2022-07-21 [?] RSPM (R 4.2.0)
#>  P R.methodsS3   1.8.2   2022-06-13 [?] RSPM (R 4.2.0)
#>  P R.oo          1.25.0  2022-06-12 [?] RSPM (R 4.2.0)
#>  P R.utils       2.12.2  2022-11-11 [?] RSPM (R 4.2.0)
#>  P R6            2.5.1   2021-08-19 [?] CRAN (R 4.2.3)
#>  P Rcpp          1.0.10  2023-01-22 [?] CRAN (R 4.2.3)
#>  P reprex        2.0.2   2022-08-17 [?] RSPM (R 4.2.0)
#>  P rlang         1.1.0   2023-03-14 [?] CRAN (R 4.2.3)
#>  P rmarkdown     2.21    2023-03-26 [?] RSPM (R 4.2.0)
#>  P rstudioapi    0.14    2022-08-22 [?] CRAN (R 4.2.3)
#>  P sass          0.4.5   2023-01-24 [?] CRAN (R 4.2.3)
#>  P sessioninfo   1.2.2   2021-12-06 [?] RSPM (R 4.2.0)
#>  P shiny       * 1.7.4   2022-12-15 [?] RSPM (R 4.2.0)
#>  P styler        1.9.1   2023-03-04 [?] RSPM (R 4.2.0)
#>  P vctrs         0.6.1   2023-03-22 [?] CRAN (R 4.2.3)
#>  P webshot       0.5.4   2022-09-26 [?] RSPM (R 4.2.0)
#>  P withr         2.5.0   2022-03-03 [?] CRAN (R 4.2.3)
#>  P xfun          0.38    2023-03-24 [?] CRAN (R 4.2.3)
#>  P xtable        1.8-4   2019-04-21 [?] RSPM (R 4.2.0)
#>  P yaml          2.3.7   2023-01-23 [?] CRAN (R 4.2.3)
#> 
#>  [1] /home/riyadh/idata/news-dashboard/renv/library/R-4.2/x86_64-pc-linux-gnu
#>  [2] /home/riyadh/idata/news-dashboard/renv/sandbox/R-4.2/x86_64-pc-linux-gnu/9a444a72
#>  [3] /usr/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

Hello, I'm trying to use bslib's card with the full_screen feature. The feature is working normally in markdown but is not working within a shiny app.

Please see the above minimal example with session info. I couldn't find anyone reporting such issues on posit community or in stackoverflow.

Thanks.


Solution

  • As shown here, you will need to use bslib::page_fluid instead of shiny::fluidPage to work with bslib's recommended version of Bootstrap (currently version 5):

    library(shiny)
    library(bslib)
    
    ui <- page_fluid(bslib::card(
      full_screen = TRUE,
      bslib::card_header("Full screen is working just fine within shiny")
    ))
    
    server <- function(input, output, session) {}
    shinyApp(ui, server)
    

    Please see this related GitHub issue.