Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 1 | --- |
| 2 | title: "htmlTable_styling Guide" |
| 3 | output: |
| 4 | html_document: |
| 5 | number_sections: true |
| 6 | vignette: > |
| 7 | %\VignetteIndexEntry{htmlTable Styling Guide} |
| 8 | %\VignetteEngine{knitr::rmarkdown} |
| 9 | %\VignetteEncoding{UTF-8} |
| 10 | --- |
| 11 | |
| 12 | # Basic HTML |
| 13 | ```{r} |
| 14 | library(knitr) |
| 15 | library(kableExtra) |
| 16 | dt <- mtcars[1:5, 1:2] |
| 17 | |
| 18 | kable(dt, format = "html") |
| 19 | ``` |
| 20 | |
| 21 | # Basic Bootstrap Table |
| 22 | ```{r} |
| 23 | kable(dt, format = "html", table.attr = htmlTable_styling()) |
| 24 | ``` |
| 25 | |
| 26 | # Boostrap Table Options |
| 27 | ## Striped |
| 28 | ```{r} |
| 29 | kable(dt, format = "html", table.attr = htmlTable_styling(bootstrap_options = "striped")) |
| 30 | ``` |
| 31 | |
| 32 | ## Striped + Hover |
| 33 | ```{r} |
| 34 | kable(dt, format = "html", table.attr = htmlTable_styling(c("striped", "hover"))) |
| 35 | ``` |
| 36 | |
| 37 | ## Other bootstrap options |
| 38 | ```{r} |
| 39 | kable(dt, format = "html", |
| 40 | table.attr = htmlTable_styling(c("striped", "bordered", "hover", "condensed", "responsive"))) |
| 41 | ``` |
| 42 | |
| 43 | # "Thin" Table and Floating options |
| 44 | ```{r} |
| 45 | kable(dt, format = "html", |
| 46 | table.attr = htmlTable_styling( |
| 47 | c("striped", "bordered", "condensed"), |
Hao Zhu | 59f5fe0 | 2017-02-22 11:27:14 -0500 | [diff] [blame^] | 48 | full_width = F |
| 49 | )) |
| 50 | ``` |
| 51 | |
| 52 | ```{r} |
| 53 | kable(dt, format = "html", |
| 54 | table.attr = htmlTable_styling( |
| 55 | c("striped", "bordered", "condensed"), |
| 56 | full_width = F, |
| 57 | float = "left" |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 58 | )) |
| 59 | ``` |
| 60 | |
| 61 | |
| 62 | |