from reactable import Reactable, Theme, options, embed_css
from reactable.data import cars_93
embed_css()
Theming
Themes provide a powerful way to customize table styling that can be reused across tables. You can either set theme variables to change the default styles (e.g., row stripe color), or add your own custom CSS to specific elements of the table.
To apply a theme, provide a Theme()
as the theme=
argument:
Reactable(
cars_93,=True,
searchable=True,
striped=True,
highlight=True,
bordered=Theme(
theme="#dfe2e5",
border_color="#f6f8fa",
striped_color="#f0f5f9",
highlight_color="8px 12px",
cell_padding={
style"font-family": "-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif"
},={"width": "100%"},
search_input_style
), )
Global theme
To set the default theme for all tables, set the global reactable.options.theme
attribute:
= Theme(
options.theme ="hsl(233, 9%, 87%)",
color="hsl(233, 9%, 19%) !important",
background_color="hsl(233, 9%, 22%) !important",
border_color="hsl(233, 12%, 22%)",
striped_color="hsl(233, 12%, 24%)",
highlight_color={"background-color": "hsl(233, 9%, 25%) !important"},
input_style={"background-color": "hsl(233, 9%, 25%)"},
select_style={"background-color": "hsl(233, 9%, 25%)"},
page_button_hover_style={"background-color": "hsl(233, 9%, 28%)"},
page_button_active_style
)
Reactable(
cars_93,=True,
filterable=True,
show_page_size_options=True,
striped=True,
highlight=lambda index: f"Details for row {index}",
details )
To restore options to the defaults, use the .reset()
method:
options.reset()