Custom theming in Shiny & R Markdown with bslib & thematic
January 21, 2021
Custom theming in Shiny and R Markdown often requires writing styling rules in both CSS and R. In particular, styles for HTML content (e.g., actionButton()
, tabsetPanel()
, titlePanel()
, etc) derive from Bootstrap CSS, so customization is traditionally done by overwriting that CSS, which is difficult to do 100% correctly. The {bslib}
package helps solve this problem by making it easy to customize (any version of) Bootstrap CSS defaults from R. However, this only solves part of the problem since CSS doesn't necessarily effect output(s) rendered by R, such as plotOutput()
. The {thematic}
package helps solve this problem by providing auto theming of plotOutput()
s (based on CSS) as well as a simple interface for styling any R graphic for any output format.
Carson Sievert, Wolfram King, and Dean Marchiori Q&A
Carson is a software engineer at RStudio working on R packages such as shiny, shinymeta, and plotly. His book “Interactive data visualization with R, plotly, and shiny”, published by CRC Press, is also freely available online at plotly-r.com.