Auto theming is really only "guaranteed" to work inside of a shiny runtime. In any other context, auto theming is based on a set of heuristics, which won't fit every use case. As a workaround, this function allows one to configure both a preference for specific auto values (e.g., bg, fg, etc) as well as the priority that certain information should receive.

auto_config(
  bg = NULL,
  fg = NULL,
  accent = NULL,
  font = NULL,
  priority = c("shiny", "config", "bslib", "rstudio")
)

auto_config_set(config)

auto_config_get()

Arguments

bg

a background color.

fg

a foreground color.

accent

a color for making certain graphical markers 'stand out' (e.g., the fitted line color for ggplot2::geom_smooth()). Can be 2 colors for lattice (stroke vs fill accent).

font

a font_spec() object. If missing, font defaults are not altered.

priority

the order of priority to use when resolving auto values. Possible values include:

config

a auto_config() object.

Value

a config (list-like) object.

Details

Configuring auto theming behavior is especially useful for developers of a custom rmarkdown output document that wish to have more sensible auto theming behavior for users of the document. In particular, by having the output document call auto_config_set() "pre-knit" with the document's styling preferences (and restoring the old defaults "post-knit"), users of the output document can then simply call thematic_on() within their document to use those preferences.

Call this function with no arguments to get the current auto defaults.

Examples

old_config <- auto_config_set(auto_config("black", "white"))
thematic_with_theme(
  thematic_theme(), {
    plot(1:10, 1:10)
 })
#> Warning: thematic was unable to resolve `accent='auto'`. Try providing an actual color (or `NA`) to the `accent` argument of `thematic_on()`. By the way, 'auto' is only officially supported in `shiny::renderPlot()`, some rmarkdown scenarios (specifically, `html_document()` with `theme!=NULL`), in RStudio, or if `auto_config_set()` is used.

auto_config_set(old_config)