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 | |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 12 | # Plain HTML |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 13 | ```{r} |
| 14 | library(knitr) |
| 15 | library(kableExtra) |
| 16 | dt <- mtcars[1:5, 1:2] |
| 17 | |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 18 | kable_input <- kable(dt, format = "html") |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 19 | ``` |
| 20 | |
| 21 | # Basic Bootstrap Table |
| 22 | ```{r} |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 23 | kable(dt, format = "html") %>% |
| 24 | htmlTable_styling() |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 25 | ``` |
| 26 | |
| 27 | # Boostrap Table Options |
| 28 | ## Striped |
| 29 | ```{r} |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 30 | kable(dt, format = "html") %>% |
| 31 | htmlTable_styling(bootstrap_options = "striped") |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 32 | ``` |
| 33 | |
| 34 | ## Striped + Hover |
| 35 | ```{r} |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 36 | kable(dt, format = "html") %>% |
| 37 | htmlTable_styling(c("striped", "hover")) |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 38 | ``` |
| 39 | |
| 40 | ## Other bootstrap options |
| 41 | ```{r} |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 42 | kable(dt, format = "html") %>% |
| 43 | htmlTable_styling(c("striped", "bordered", "hover", "condensed", "responsive")) |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 44 | ``` |
| 45 | |
| 46 | # "Thin" Table and Floating options |
| 47 | ```{r} |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 48 | kable(dt, format = "html") %>% |
| 49 | htmlTable_styling(c("striped", "bordered", "condensed"), full_width = F) |
Hao Zhu | 59f5fe0 | 2017-02-22 11:27:14 -0500 | [diff] [blame] | 50 | ``` |
| 51 | |
| 52 | ```{r} |
Hao Zhu | 2623412 | 2017-02-22 15:34:33 -0500 | [diff] [blame] | 53 | kable(dt, format = "html") %>% |
Hao Zhu | 981933b | 2017-02-22 18:46:23 -0500 | [diff] [blame^] | 54 | htmlTable_styling(c("striped", "bordered", "condensed"), full_width = F, float = "left") %>% |
| 55 | htmlTable_add_header_above(c("", "Names" = 2)) |
Hao Zhu | 9495658 | 2017-02-21 18:18:29 -0500 | [diff] [blame] | 56 | ``` |
| 57 | |
| 58 | |
| 59 | |