reactable package in R is a powerful and flexible
tool for creating interactive and customizable tables
in web applications and R Shiny dashboards.
It mainly provides one function:
reactable() allowing to
create a table from a data frame.
✍️ author → Greg Lin
📘 documentation → github
⭐️ more than 500 stars on github
This is how a default
reactable table looks like:
To get started with
reactable, you can install it
directly from CRAN using the
reactable package provides one main function:
reactable(). It takes a data frame as input and returns an
This is how the table above was produced:
You can enable searching by setting the
You can enable filtering by setting the
You can enable grouping and aggregating by setting
groupBy argument to the name of a column and by adding
aggregate argument in each column definition.
table <- reactable(iris, groupBy = "Species", # Group by the Species column columns = list( Sepal.Length = colDef(aggregate = "max"), # max value Sepal.Width = colDef(aggregate = "mean", format = colFormat(digits = 1)), # mean value Petal.Length = colDef(aggregate = "unique"), # unique values Petal.Width = colDef(aggregate = "min") # min value ) ) table
You can customize the appearance of the table by setting the
theme argument to a
reactableTheme object. You
can also use the
arguments to add stripes or highlight
the hovered row.
table <- reactable( iris[1:30, ], striped = TRUE, highlight = TRUE, theme = reactableTheme( borderColor = "#dfe2e5", stripedColor = "#f6f8fa", highlightColor = "red", cellPadding = "8px 12px", style = list(fontFamily = "-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif"), searchInputStyle = list(width = "100%") )) table