thematic
Theme ggplot2, lattice, and base graphics based on a few simple settings
The thematic package provides simplified, centralized theming for ggplot2, lattice, and base R graphics. It enables automatic styling of R plots in Shiny apps, R Markdown documents, and RStudio by detecting relevant background, foreground, and accent colors from the environment.
The package automatically adapts plots to match CSS themes in Shiny, RStudio IDE themes, and bslib-powered R Markdown documents without manual configuration. It supports custom fonts including Google Fonts, provides sensible defaults for qualitative and sequential color scales, and allows manual override of any styling through standard plot-specific theming code. This eliminates the need to manually coordinate colors and fonts across different plotting systems.
Contributors#
Resources featuring thematic#
How to bring modern UI to your Shiny apps
Looking for ways to make your Shiny apps a little…shinier?
Join Garrett Grolemund at Posit on Wednesday, January 31st at 11 am ET to learn how to theme and brand your own apps.
The session will highlight how to:
Layout an app with the bslib package (modern UI toolkit with no knowledge of CSS required) Add cards, value boxes, and logos Customize the theme of the app Tweak the theme by swapping out primary colors, secondary colors, and more. Quickly apply the theme to every plot in the app Work with bootstrap classes
Helpful Resources: ️ Code at : https://github.com/garrettgman/shiny-styling-demo bslib package: https://rstudio.github.io/bslib/ bsicons package: https://github.com/rstudio/bsicons ️ Bootstrap icons: https://icons.getbootstrap.com/ ️ Bootstrap CSS classes: https://bootstrapshuffle.com/classes thematic package: https://rstudio.github.io/thematic/ gitlink package: https://github.com/colearendt/gitlink
️ Follow-up links: Posit Team: https://posit.co/products/enterprise/team/ Request evaluation: pos.it/chat-with-us Posit Team demo resources: pos.it/demo-resources
LIVE Q&A ROOM for ~11:45 am on January 31st: https://youtube.com/live/1G8ZM6kbt8c?feature=share
There is no need to register; join us here on YouTube at the time above or you can add to your calendar using the link below:
pos.it/team-demo
We host these Workflow Demos on the last Wednesday of every month, so you can use the link above to add the recurring event as well
Carson Sievert || Developing Shiny Custom Themes in Real Time Using {bslib}| RStudio
00:00 Introduction 00:09 The magic of bs_theme_preview() 01:43 The interactive widget provided by bs_theme_preview() 02:12 Using Bootswatch themes 02:57 Using the interactive widget to adjust your theme in real time 03:38 Integration with Google Fonts 04:22 Thematic is enabled in bs_theme_preview() 04:45 DT tables is enabled in bs_theme_preview() 05:30 Going from the interactive widget to your R code 07:03 Using interactive theming on your own Shiny app 09:01 Interactive theming with R Markdown documents
The bs_theme_preview() function launches an example shiny app via run_with_themer() and bs_theme_dependencies(). This is useful for getting a quick preview of the current theme setting as well as an interactive GUI for tweaking some of the main theme settings. Link to docs: https://rstudio.github.io/bslib/reference/bs_theme_preview.html
You can read more about the bslib package here: https://rstudio.github.io/bslib/ And you can learn more about Shiny here: https://shiny.rstudio.com/
Got questions? The RStudio Community site is a great place to get assistance: https://community.rstudio.com/
Content: Carson Sievert (@cpsievert) Design and editing: Jesse Mostipak (@kierisi)

Carson Sievert || Custom Theming with {bslib} in Shiny and R Markdown using bs_theme() || RStudio
00:00 Introduction 01:15 Jumping right in with the theme argument in Shiny 01:31 Shiny’s classic navbarPage using bs_theme() 01:46 Specifying your Bootstrap version 02:31 Using the theme argument in R Markdown 03:17 Custom theming in R Markdown using bs_theme() 04:10 bslib templates provided by RStudio 05:33 Review of common arguments for the theme parameter 08:47 Tips for working with dark themes 10:34 Introduction to the thematic package, which styles plots 12:04 How thematic handles fonts 13:09 Using fonts with bslib in R Markdown 14:36 Moving a theme from an R Markdown document into a Shiny app 16:51 Setting warnings for contrast ratios 18:42 A quick tour of Bootstrap 4 and Bootstrap 5 Sass variables 20:35 A quick overview of writing custom HTML in Shiny 22:15 How bslib automatically handles color contrast ratios
bs_theme() allows you to creates a Bootstrap theme object, where you can choose a (major) Bootstrap version, choose a Bootswatch theme (optional), customize main colors and fonts via explicitly named arguments (e.g., bg, fg, primary, etc), and customize other, lower-level, Bootstrap Sass variable defaults via ….
You can read more about the bslib package here: https://rstudio.github.io/bslib/ And you can learn more about Shiny here: https://shiny.rstudio.com/
Got questions? The RStudio Community site is a great place to get assistance: https://community.rstudio.com/
Content: Carson Sievert (@cpsievert) Design and editing: Jesse Mostipak (@kierisi)

Tom Mock & Shannon Haggerty | Theming Shiny and RMarkdown with {thematic} & {bslib} | RStudio
From rstudio::global(2021) Shiny X-Sessions, sponsored by Appsilon: this presentation covers the basics of how the thematic and bslib packages can be used to consistently style all the components of a shiny app at once.
About Tom Mock: Thomas is involved in the local and global data science community, serving as Outreach Coordinator for the Dallas R User Group, as a mentor for the R for Data Science Online Learning Community, as co-founder of #TidyTuesday, attending various Data Science and R-related conferences/meetups, and participated in Startup Weekend Fort Worth as a data scientist/entrepreneur.
About Shannon Haggerty: Shannon is on RStudio’s Customer Success team working with teams across the Life Sciences and Healthcare. In her free time, she likes to bake, hang out with her dogs, and explore new hobbies.
Learn more about the rstudio::global(2021) X-Sessions: https://blog.rstudio.com/2021/01/11/x-sessions-at-rstudio-global/


