rshinybslib

How can I extract the font from a bslib theeme?


I would like to extract the different fonts from a theme that are created by bslib. There is a function called bs_get_variables but i does not seem to return any font-familes.

vars <- c("body-bg", "body-color", "primary", "border-radius", "font-family", "base_font", "code_font", "heading_font")
bs_get_variables(bs_theme(bootswatch = "sketchy"), varnames = vars)

Solution

  • See the documentation at https://rstudio.github.io/bslib/articles/bs5-variables/index.html

    library(bslib)
    vars <- c("body-bg", "body-color", "primary", "border-radius", "font-family-sans-serif", "font-family-monospace", "font-family-base", "headings-font-family", "font-family-code")
    bs_get_variables(bs_theme(bootswatch = "sketchy"), varnames = vars)
    

    Gives:

                                                                                                                body-bg 
                                                                                                                 "#fff" 
                                                                                                             body-color 
                                                                                                              "#212529" 
                                                                                                                primary 
                                                                                                                 "#333" 
                                                                                                          border-radius 
                                                                                                                 "25px" 
                                                                                                 font-family-sans-serif 
    "Neucha, -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif" 
                                                                                                  font-family-monospace 
                             "SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace" 
                                                                                                       font-family-base 
                                                                                            "var(--bs-font-sans-serif)" 
                                                                                                   headings-font-family 
                                                                                            "\"Cabin Sketch\", cursive" 
                                                                                                       font-family-code 
                                                                                             "var(--bs-font-monospace)"