Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

bs_get_variables

Retrieve Sass variable values from the current theme


Description

Useful for retriving a variable from the current theme and using the value to inform another R function.

Usage

bs_get_variables(theme, varnames)

bs_get_contrast(theme, varnames)

Arguments

theme

a bs_theme() object.

varnames

a character string referencing a Sass variable in the current theme.

Value

a character string containing a CSS/Sass value. If the variable(s) are not defined, their value is NA.

Examples

vars <- c("body-bg", "body-color", "primary", "border-radius")
bs_get_variables(bs_theme(), varnames = vars)
bs_get_variables(bs_theme(bootswatch = "darkly"), varnames = vars)


bs_get_contrast(bs_theme(), c("primary", "dark", "light"))

library(htmltools)
div(
  class = "bg-primary",
  style = css(
    color = bs_get_contrast(bs_theme(), "primary")
  )
)

bslib

Custom 'Bootstrap' 'Sass' Themes for 'shiny' and 'rmarkdown'

v0.2.4
MIT + file LICENSE
Authors
Carson Sievert [aut, cre], Joe Cheng [aut], RStudio [cph], Bootstrap contributors [ctb] (Bootstrap library), Twitter, Inc [cph] (Bootstrap library), Javi Aguilar [ctb, cph] (Bootstrap colorpicker library), Thomas Park [ctb, cph] (Bootswatch library), PayPal [ctb, cph] (Bootstrap accessibility plugin)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.