You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bslib stylesheet overrides do not work with shiny_prerendered and rmarkdown2.8 #343
Referencing stylesheets in the front matter will not override the Bootstrap theme with flexdashboard and runtime: shiny_prerendered. This only appears to be an issue in rmarkdown2.8.
bslib allows for style overrides by specifying stylesheets in the css property in the front matter. This works when rendering html_documents (both shiny and shiny_prerendered). It also works in flexdashboard when using runtime: shiny, but not with runtime: shiny_prerendered.
This happens because, in the non-{bslib} usage of html_document (i.e., no specified theme), css files appear before bootstrap (as shown in your screenshot). However, in the {bslib} case, css will be included after Bootstrap, so you can workaround the issue like this:
---
title: "bslib css overrides"runtime: shiny_prerenderedoutput:
flexdashboard::flex_dashboard:
theme:
version: 4# Include the font files as well!base_font:
google: Press Start 2Pcss:
- https://unpkg.com/nes.css@latest/css/nes.min.css
---
```{r, context="server"}print("Hello World")```
I feel like, in the non-{bslib} case, css should appear after Bootstrap, but it might be too late to change that (cc @cderv).
@cpsievert even without bslib, the CSS should be inserted after the HTML dependencies, including bootstrap.
This is an issue here specific to flexdashboard because while fixing something with shiny_prerendered in rmarkdown, we did not made the change to flexdashboard own custom template. A specific placeholder needs to be inserted into the template so that the HTML dependencies are inserted in the correct place. This is because header-includes Pandoc's variable is not used with shiny and the HTML dependencies where added at the end of the <head> leading to the behavior above. The PR introduce the missing piece which should fix the issue.
Activity
cpsievert commentedon Jun 17, 2021
This happens because, in the non-
{bslib}usage ofhtml_document(i.e., no specifiedtheme),cssfiles appear before bootstrap (as shown in your screenshot). However, in the{bslib}case,csswill be included after Bootstrap, so you can workaround the issue like this:I feel like, in the non-
{bslib}case,cssshould appear after Bootstrap, but it might be too late to change that (cc @cderv).cderv commentedon Jun 22, 2021
I just pushed a fix for this I believe. @joemirizio can you try the PR ?
@cpsievert even without bslib, the CSS should be inserted after the HTML dependencies, including bootstrap.
This is an issue here specific to flexdashboard because while fixing something with shiny_prerendered in rmarkdown, we did not made the change to flexdashboard own custom template. A specific placeholder needs to be inserted into the template so that the HTML dependencies are inserted in the correct place. This is because
header-includesPandoc's variable is not used with shiny and the HTML dependencies where added at the end of the<head>leading to the behavior above. The PR introduce the missing piece which should fix the issue.joemirizio commentedon Jun 23, 2021
Thanks for looking into this! I tested with the PR version and it worked great