blob: a91152d1877abf664e947f0132548ff03415511d [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.
Hao Zhud7762a42020-08-10 09:05:47 -040010#' @param lightable_options Options to customize lightable. Similar with
11#' `bootstrap_options` in `kable_styling`. Choices include `basic`, `striped`
12#' and `hover`.
Hao Zhuad4ea392020-08-10 01:24:50 -040013#' @param ... Everything else you need to specify in `kable_styling`.
14#'
15#' @export
Hao Zhud7762a42020-08-10 09:05:47 -040016kable_classic <- function(kable_input, lightable_options = "basic", ...) {
Hao Zhuad4ea392020-08-10 01:24:50 -040017 light_class <- "lightable-classic"
Hao Zhud7762a42020-08-10 09:05:47 -040018 lightable_options <- match.arg(lightable_options,
19 choices = c("basic", "striped", "hover"),
20 several.ok = TRUE)
21 if ("striped" %in% lightable_options) {
Hao Zhuad4ea392020-08-10 01:24:50 -040022 light_class <- paste(light_class, "lightable-striped")
23 }
Hao Zhud7762a42020-08-10 09:05:47 -040024 if ("hover" %in% lightable_options) {
Hao Zhuad4ea392020-08-10 01:24:50 -040025 light_class <- paste(light_class, "lightable-hover")
26 }
27 kable_styling(kable_input, "none", lightable_class = light_class, ...)
28}
29
30#' @rdname kable_classic
31#' @export
Hao Zhud7762a42020-08-10 09:05:47 -040032kable_minimal <- function(kable_input, lightable_options = "basic", ...) {
Hao Zhuad4ea392020-08-10 01:24:50 -040033 light_class <- "lightable-minimal"
Hao Zhud7762a42020-08-10 09:05:47 -040034 lightable_options <- match.arg(lightable_options,
35 choices = c("basic", "striped", "hover"),
36 several.ok = TRUE)
37 if ("striped" %in% lightable_options) {
Hao Zhuad4ea392020-08-10 01:24:50 -040038 light_class <- paste(light_class, "lightable-striped")
39 }
Hao Zhud7762a42020-08-10 09:05:47 -040040 if ("hover" %in% lightable_options) {
Hao Zhuad4ea392020-08-10 01:24:50 -040041 light_class <- paste(light_class, "lightable-hover")
42 }
43 kable_styling(kable_input, "none", lightable_class = light_class, ...)
44}
45
46#' @rdname kable_classic
47#' @export
Hao Zhud7762a42020-08-10 09:05:47 -040048kable_material <- function(kable_input, lightable_options = "basic", ...) {
Hao Zhuad4ea392020-08-10 01:24:50 -040049 light_class <- "lightable-material"
Hao Zhud7762a42020-08-10 09:05:47 -040050 lightable_options <- match.arg(lightable_options,
51 choices = c("basic", "striped", "hover"),
52 several.ok = TRUE)
53 if ("striped" %in% lightable_options) {
Hao Zhuad4ea392020-08-10 01:24:50 -040054 light_class <- paste(light_class, "lightable-striped")
55 }
Hao Zhud7762a42020-08-10 09:05:47 -040056 if ("hover" %in% lightable_options) {
Hao Zhuad4ea392020-08-10 01:24:50 -040057 light_class <- paste(light_class, "lightable-hover")
58 }
59 kable_styling(kable_input, "none", lightable_class = light_class, ...)
60}