embed_css() is currently required once, in order to add the necessary CSS.
cars_93 is a tiny built-in DataFrame implementation called SimpleFrame.
In this walkthrough, we’ll turn the cars data directly into a reactable table. If you want to explore the data, use methods like .to_polars() or .to_pandas() to convert it to a Polars or Pandas DataFrame, respectively.
cars.to_polars()
shape: (3, 6)
manufacturer
model
type
price
min_price
max_price
str
str
str
f64
f64
f64
"Acura"
"Integra"
"Small"
15.9
12.9
18.8
"Acura"
"Legend"
"Midsize"
33.9
29.2
38.7
"Audi"
"90"
"Compact"
29.1
25.9
32.3
Reactable
The Reactable() class is responsible for building the table:
The code above used filterable=True argument added filters to the top of each column, and default_page_size=2 to limit each page to 2 rows. Reactable() has many optional parameters, designed for quick customization of pieces like sorting, filtering, searching, and pagination.
It also has four parameters which combine with other classes for configuration:
name
description
columns=
use Column() to customize column names, format, and more.
column_groups=
use ColGroup() to group columns together, with a label.
theme=
use Theme() to customize table styling.
language=
use Language() to customize prompts like “Next page”.
The following sections walk through these four parameters in depth.
Column definitions
The columns= argument uses the Column() class to customize pieces like column name and value formatting (e.g. as a date or currency).
Below, we configure the name and format of the "max_price" column:
columns= maps columns of data to Column() configurations.
Column(name=...) cleans up the name displayed to “Max Price”
Column(format=...) uses ColFormat() to specify how to format column values.
The code above handled a single price column, but there are three related to price that need formatting. To avoid too much duplication, we can assign ColFormat() to a variable, and re-use that for each column definition.
The language= argument uses the Language() class to customize text prompts on the table like “Next Page”.
Reactable( cars, language=Language( page_next="TAKE ME TO THE NEXT PAGE", page_previous="GO BACK", ), default_page_size=2,)
Putting it all together
In the sections above, we customized the columns, column groupings, theme, and language individually. Now we’ll put it all together to make the complete table.