Chaining Content Classes

css content classes

Syntax trick for cleaner use of content classes

Emil Hvitfeldt true
05-20-2021

Content classes are a great tool when creating xaringan slides. Chaining is a way to apply multiple content classes to the same element with a more concise syntax.

If you were to apply .italic and .orange to a word you could write it as .italic[.orange[word]] which is already bad with just 2 classes. Chaining allows us to write .italic.orange[word] to get the same result.

Result

Rmd

---
output:
  xaringan::moon_reader:
    css: ["default", "stylesheet.css"]
    lib_dir: libs
    seal: FALSE
    nature:
      highlightStyle: github
      highlightLines: true
      countIncrementalSlides: false
---

# Sample .italic.orange[Header]

# Sample .orange.italic[Header]

# Sample .italic[.orange[Header]]

stylesheet.css

.italic {
  font-style: italic;
}

.orange {
  color: orange;
}

Reuse

Text and figures are licensed under Creative Commons Attribution CC BY 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".

Citation

For attribution, please cite this work as

Hvitfeldt (2021, May 20). Xaringan Gallery: Chaining Content Classes. Retrieved from https://xaringan.gallery/examples/chaining-content-classes/

BibTeX citation

@misc{hvitfeldt2021chaining,
  author = {Hvitfeldt, Emil},
  title = {Xaringan Gallery: Chaining Content Classes},
  url = {https://xaringan.gallery/examples/chaining-content-classes/},
  year = {2021}
}