knitr::opts_chunk$set(echo = TRUE)

library(reactable)

::: {.callout} New in v0.4.0 :::

Introduction

Static rendering is an optional feature that allows you to render tables to static HTML in R.

By default, tables are rendered completely in the user's browser by JavaScript, and there's no actual HTML being generated when you run reactable() in R.

This means when you load a page, tables will be blank at first, and then appear a short time later as they get rendered. In extreme cases, it can take a noticeably long time for tables to appear, like with the heavy Examples without static rendering page.

With static rendering, tables are pre-rendered to their initial HTML so they appear immediately without any flash of content. Tables are then made interactive and subsequently rendered by JavaScript as needed. You can try refreshing on the Examples with static rendering page for a comparison.

Advantages:

Static rendering uses the V8 JavaScript engine provided by the V8 package. V8 is not installed with reactable by default, so it must be installed before using static rendering.

::: {.callout-note} Note: Static rendering is currently experimental, and is not supported for tables rendered via reactableOutput() in Shiny. There are also other limitations and tradeoffs to consider, and static rendering may not make sense for every table. :::

Usage

To use static rendering, ensure that the V8 package is installed first. V8 is not installed with reactable by default.

install.packages("V8")

Then, use reactable(static = TRUE) to render a single table to static HTML:

data <- MASS::Cars93[, c("Manufacturer", "Model", "Type", "Price")]

reactable(data, defaultPageSize = 5, static = TRUE)

Or use options(reactable.static = TRUE) to enable static rendering for all tables:

options(reactable.static = TRUE)

reactable(data, defaultPageSize = 5)
options(reactable.static = FALSE)

Examples

The reactable package documentation uses static rendering in several articles, and provides alternate versions of these pages without static rendering for comparison:

Limitations and Tradeoffs

Although static rendering might seem useful to enable for all tables, there are some limitations and tradeoffs to consider, and it may not make sense to use for every table.

```{css echo=FALSE} / rmarkdown html documents / .main-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; }

.main-container blockquote { font-size: inherit; } ```



glin/reactable documentation built on Jan. 25, 2025, 7:41 p.m.