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