Hao Zhu | 6007040 | 2020-08-11 20:52:12 -0400 | [diff] [blame^] | 1 | --- |
| 2 | title: "Contributing Additional HTML Table Themes to kableExtra" |
| 3 | output: html_document |
| 4 | --- |
| 5 | |
| 6 | ```{r setup, include=FALSE} |
| 7 | knitr::opts_chunk$set(echo = TRUE) |
| 8 | ``` |
| 9 | |
| 10 | The latest version of `kableExtra` allows users to use some alternative |
| 11 | table themes, in addition to the default `bootstrap 3` theme. See the [Alternative themes](https://haozhu233.github.io/kableExtra/awesome_table_in_html.html#Alternative_themes) section for details. Here is a simple guide on how to add new themes to this package. |
| 12 | |
| 13 | To add a new theme, you only need to do two things: |
| 14 | |
| 15 | 1. Design some CSS for tables using frontend playground tools such as [jsfiddle](http://jsfiddle.net) and import them to [this file](https://github.com/haozhu233/kableExtra/blob/master/inst/lightable-0.0.1/lightable.css) |
| 16 | 2. Create a corresponding function in [R/light_themes.R](https://github.com/haozhu233/kableExtra/blob/master/R/light_themes.R) |
| 17 | |
| 18 | Why it works? `kable_styling` works by adding corresponding bootstrap table classes to the html object. This time, instead of adding a bootstrap table class, we can choose to add a css class we defined. On the other hand, our css file gets loaded to either the rmarkdown environment or R console as a regular `htmlDependency()` when the tables get printed. |