blob: c4917c52e0f541bbb9123b53c529c562129b160d [file] [log] [blame]
Hao Zhu94956582017-02-21 18:18:29 -05001---
2title: "htmlTable_styling Guide"
3output:
4 html_document:
5 number_sections: true
6vignette: >
7 %\VignetteIndexEntry{htmlTable Styling Guide}
8 %\VignetteEngine{knitr::rmarkdown}
9 %\VignetteEncoding{UTF-8}
10---
11
Hao Zhu26234122017-02-22 15:34:33 -050012# Plain HTML
Hao Zhu94956582017-02-21 18:18:29 -050013```{r}
14library(knitr)
15library(kableExtra)
16dt <- mtcars[1:5, 1:2]
17
Hao Zhu26234122017-02-22 15:34:33 -050018kable_input <- kable(dt, format = "html")
Hao Zhu94956582017-02-21 18:18:29 -050019```
20
21# Basic Bootstrap Table
22```{r}
Hao Zhu26234122017-02-22 15:34:33 -050023kable(dt, format = "html") %>%
24 htmlTable_styling()
Hao Zhu94956582017-02-21 18:18:29 -050025```
26
27# Boostrap Table Options
28## Striped
29```{r}
Hao Zhu26234122017-02-22 15:34:33 -050030kable(dt, format = "html") %>%
31 htmlTable_styling(bootstrap_options = "striped")
Hao Zhu94956582017-02-21 18:18:29 -050032```
33
34## Striped + Hover
35```{r}
Hao Zhu26234122017-02-22 15:34:33 -050036kable(dt, format = "html") %>%
37 htmlTable_styling(c("striped", "hover"))
Hao Zhu94956582017-02-21 18:18:29 -050038```
39
40## Other bootstrap options
41```{r}
Hao Zhu26234122017-02-22 15:34:33 -050042kable(dt, format = "html") %>%
43 htmlTable_styling(c("striped", "bordered", "hover", "condensed", "responsive"))
Hao Zhu94956582017-02-21 18:18:29 -050044```
45
46# "Thin" Table and Floating options
47```{r}
Hao Zhu26234122017-02-22 15:34:33 -050048kable(dt, format = "html") %>%
49 htmlTable_styling(c("striped", "bordered", "condensed"), full_width = F)
Hao Zhu59f5fe02017-02-22 11:27:14 -050050```
51
52```{r}
Hao Zhu26234122017-02-22 15:34:33 -050053kable(dt, format = "html") %>%
Hao Zhu981933b2017-02-22 18:46:23 -050054 htmlTable_styling(c("striped", "bordered", "condensed"), full_width = F, float = "left") %>%
55 htmlTable_add_header_above(c("", "Names" = 2))
Hao Zhu94956582017-02-21 18:18:29 -050056```
57
58
59