Learn R Programming

kableExtra (version 1.4.0)

scroll_box: Put a HTML table into a scrollable box

Description

This function will put a HTML kable object in a fixed-height, fixed-width or both box and make it scrollable.

Usage

scroll_box(
  kable_input,
  height = NULL,
  width = NULL,
  box_css = "border: 1px solid #ddd; padding: 5px; ",
  extra_css = NULL,
  fixed_thead = TRUE
)

Arguments

kable_input

A HTML kable object

height

A character string indicating the height of the box, e.g. "50px"

width

A character string indicating the width of the box, e.g. "100px"

box_css

CSS text for the box

extra_css

Extra CSS styles

fixed_thead

HTML table option so table header row is fixed at top. Values can be either T/F or list(enabled = T/F, background = "anycolor").

Examples

Run this code
if (FALSE) {
# Specify table size by pixels
kable(cbind(mtcars, mtcars), "html") %>%
    kable_styling() %>%
    scroll_box(width = "500px", height = "200px")

# Specify by percent
kable(cbind(mtcars, mtcars), "html") %>%
    kable_styling() %>%
    scroll_box(width = "100%", height = "200px")
}

Run the code above in your browser using DataLab