blob: f1ec579ca65a3fddd4de101074fd1adee3efb17e [file] [log] [blame]
Hao Zhuad4ea392020-08-10 01:24:50 -04001#' Alternative HTML themes
2#'
3#' @description kableExtra uses the built-in bootstrap themes by default in
4#' `kable_styling()`. Alternatively, you can use a customized table themes for
5#' your table. This `lightable` table style sheet comes with three formats,
6#' namely `lightable-minimal`, `lightable-classic` and `lightable-material` with
7#' `hover` and `striped` options.
8#'
9#' @param kable_input A HTML kable object.
10#' @param striped T/F for adding striped rows.
11#' @param hover T/F for adding hover effects.
12#' @param ... Everything else you need to specify in `kable_styling`.
13#'
14#' @export
15kable_classic <- function(kable_input, striped = FALSE,
16 hover = FALSE, ...) {
17 light_class <- "lightable-classic"
18 if (striped) {
19 light_class <- paste(light_class, "lightable-striped")
20 }
21 if (hover) {
22 light_class <- paste(light_class, "lightable-hover")
23 }
24 kable_styling(kable_input, "none", lightable_class = light_class, ...)
25}
26
27#' @rdname kable_classic
28#' @export
29kable_minimal <- function(kable_input, striped = FALSE,
30 hover = FALSE, ...) {
31 light_class <- "lightable-minimal"
32 if (striped) {
33 light_class <- paste(light_class, "lightable-striped")
34 }
35 if (hover) {
36 light_class <- paste(light_class, "lightable-hover")
37 }
38 kable_styling(kable_input, "none", lightable_class = light_class, ...)
39}
40
41#' @rdname kable_classic
42#' @export
43kable_material <- function(kable_input, striped = FALSE,
44 hover = FALSE, ...) {
45 light_class <- "lightable-material"
46 if (striped) {
47 light_class <- paste(light_class, "lightable-striped")
48 }
49 if (hover) {
50 light_class <- paste(light_class, "lightable-hover")
51 }
52 kable_styling(kable_input, "none", lightable_class = light_class, ...)
53}