7.5 CSS and themes

The format xaringan::moon_reader has a css option, to which you can pass a vector of CSS file paths, e.g.,

---
output:
  xaringan::moon_reader:
    css: ["default", "extra.css"]
---

In theory, the file path should contain the extension .css. If a path does not contain a filename extension, it is assumed to be a built-in CSS file in the xaringan package. For example, default in the above example means default.css in the package under the path xaringan:::pkg_resource(). To see all built-in CSS files, call xaringan:::list_css() in R.

When you only want to override a few CSS rules in the default theme, you do not have to copy the whole file default.css; instead, create a new (and hopefully smaller) CSS file that only provides new CSS rules.

Users have contributed a few themes to xaringan. For example, you can use the metropolis theme (https://github.com/pat-s/xaringan-metropolis):

---
output:
  xaringan::moon_reader:
    css: [default, metropolis, metropolis-fonts]
---

To see all possible themes:

names(xaringan:::list_css())
##  [1] "chocolate-fonts"  "chocolate"       
##  [3] "default-fonts"    "default"         
##  [5] "duke-blue"        "fc-fonts"        
##  [7] "fc"               "glasgow_template"
##  [9] "hygge-duke"       "hygge"           
## [11] "ki-fonts"         "ki"              
## [13] "kunoichi"         "lucy-fonts"      
## [15] "lucy"             "metropolis-fonts"
## [17] "metropolis"       "middlebury-fonts"
## [19] "middlebury"       "nhsr-fonts"      
## [21] "nhsr"             "ninjutsu"        
## [23] "rladies-fonts"    "rladies"         
## [25] "robot-fonts"      "robot"           
## [27] "rutgers-fonts"    "rutgers"         
## [29] "shinobi"          "tamu-fonts"      
## [31] "tamu"             "uio-fonts"       
## [33] "uio"              "uo-fonts"        
## [35] "uo"               "uol-fonts"       
## [37] "uol"              "useR-fonts"      
## [39] "useR"             "uwm-fonts"       
## [41] "uwm"              "wic-fonts"       
## [43] "wic"

If you also want to contribute themes, please read the guide at https://yihui.name/en/2017/10/xaringan-themes.