rstudio / bslib

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

Should `theme` argument in `page_*()` functions accept a string? #1067

Open daattali opened 1 month ago

daattali commented 1 month ago

In shiny's page functions, the theme argument can accept either a bs_theme() object or a path to a CSS file.

In bslib's page functions, the documentation says that the only acceptable value is a bs_theme() object. However, it seems that providing a string path to a CSS file also works. Should this be accepted or no? If yes, it should be documented. If no, an error should get thrown.

cpsievert commented 1 month ago

I think the ship has probably sailed at this point for accepting a string. We also do throw an informative error:

> bslib::page("bar", theme = "foo")
Error in assert_bs_theme(theme) : `theme` must be a `bs_theme()` object
daattali commented 1 month ago

Strange, I tested on both the CRAN version and the latest github version of {bslib}, and ui <- page(theme = "style.css", "test") does work for me. No error message, and it applies the stylesheet.

cpsievert commented 1 month ago

Ahh, right, that error only gets thrown when rendered statically. Otherwise, it gets passed to shiny::bootstrapPage(), which doesn't error. Maybe we should do more to throw earlier on.