Use colDef()
to customize the columns in a table.
colDef(
name = NULL,
aggregate = NULL,
sortable = NULL,
resizable = NULL,
filterable = NULL,
show = TRUE,
defaultSortOrder = NULL,
sortNALast = FALSE,
format = NULL,
cell = NULL,
aggregated = NULL,
header = NULL,
footer = NULL,
details = NULL,
html = FALSE,
na = "",
minWidth = NULL,
maxWidth = NULL,
width = NULL,
align = NULL,
class = NULL,
style = NULL,
headerClass = NULL,
headerStyle = NULL,
footerClass = NULL,
footerStyle = NULL
)
Column header name.
Aggregate function to use when rows are grouped. The name
of a built-in aggregate function or a custom JS()
aggregate function.
Built-in aggregate functions are: "mean"
, "sum"
, "max"
, "min"
,
"median"
, "count"
, "unique"
, and "frequency"
.
To enable row grouping, use the groupBy
argument in reactable()
.
Enable sorting? Overrides the table option.
Enable column resizing? Overrides the table option.
Enable column filtering? Overrides the table option.
Show the column? Defaults to TRUE
.
Default sort order. Either "asc"
for ascending
order or "desc"
for descending order. Overrides the table option.
Column formatting options. A colFormat()
object to
format all cells, or a named list of colFormat()
objects to format standard
cells ("cell"
) and aggregated cells ("aggregated"
) separately.
Custom cell renderer. An R function that takes the cell value,
row index, and column name as arguments, or a JS()
function that takes a
cell info object as an argument.
Custom aggregated cell renderer. A JS()
function that takes
a cell info object as an argument.
Custom header renderer. An R function that takes the header value
and column name as arguments, or a JS()
function that takes a column info
object as an argument.
Footer content or render function. Render functions can be an
R function that takes two arguments, the column values and column name, or a
JS()
function that takes a column info object as an argument.
Additional content to display when expanding a row. An R function
that takes a row index argument or a JS()
function that takes a row info object
as an argument. Cannot be used on a grouping column.
Render content as HTML? Raw HTML strings are escaped by default.
Minimum width of the column in pixels. Defaults to 100.
Maximum width of the column in pixels.
Fixed width of the column in pixels. Overrides minWidth
and maxWidth
.
Column alignment. One of "left"
, "right"
, "center"
.
Additional CSS classes to apply to cells. Can also be an R function
that takes the cell value, row index, and column name as arguments, or a JS()
function that takes a row info object, column info object, and table state
object as arguments.
Note that R functions cannot apply classes to aggregated cells.
Inline styles to apply to cells. A named list or character string.
Can also be an R function that takes the cell value and row index as arguments,
or a JS()
function that takes a row info object, column info object, and
table state object as arguments.
Note that R functions cannot apply styles to aggregated cells.
If style
is a named list, property names should be camelCased.
Additional CSS classes to apply to the header.
Inline styles to apply to the header. A named list or character string.
Note that if headerStyle
is a named list, property names should be camelCased.
Additional CSS classes to apply to the footer.
Inline styles to apply to the footer. A named list or character string.
Note that if footerStyle
is a named list, property names should be camelCased.
A column definition object that can be used to customize columns
in reactable()
.
# NOT RUN {
reactable(
iris,
columns = list(
Sepal.Length = colDef(name = "Sepal Length"),
Sepal.Width = colDef(filterable = TRUE),
Petal.Length = colDef(show = FALSE),
Petal.Width = colDef(defaultSortOrder = "desc")
)
)
# }
Run the code above in your browser using DataLab