Getting started
This path produces a DataTable backed by typed application rows and generated
filter controls.
The development branch uses GPUI Kit 0.11 and Storybook 0.9. The published gpui-table 0.9 line uses Kit 0.9 and Storybook 0.8, and the gpui-table 0.8 line targets Kit 0.8. Keep these public GPUI type families together.
Prerequisites
Use Rust 1.100 or later to build the development branch. The dependency block below is for the published gpui-table 0.9 line and uses its matching Kit:
[dependencies]
gpui-kit = "0.9.0"
gpui-table = "0.9"
gpui-table-component = "0.9"
Generated table code refers to gpui_kit directly, so keep it as a direct
dependency using the version or source selected by the application. See
Features and integration crates when a row uses numeric range
filters, Fluent labels, SpacetimeDB values, or MCP.
Initialize gpui-kit during application startup, then initialize localization
for the built-in table filters:
gpui_kit::component::init(cx);
gpui_table_component::i18n::init(cx)?;
Define the rows
Derive GpuiTable on a named struct. Every visible field type must implement
TableCell; built-in scalar and date types already do. This faceted enum
derives both Filterable for its filter options and TableCell for rendering:
use gpui_table::{Filterable, GpuiTable, TableCell};
#[derive(Clone, Eq, Filterable, Hash, PartialEq, TableCell)]
enum UserStatus {
Active,
Suspended,
}
#[derive(Clone, GpuiTable)]
#[gpui_table(filters)]
struct User {
#[gpui_table(
sortable,
width = 160.,
filter(gpui_table_component::TextFilter)
)]
name: String,
#[gpui_table(
width = 120.,
filter(gpui_table_component::FacetedFilter::<UserStatus>.searchable(true))
)]
status: UserStatus,
}
Create and render the table
Construct the generated delegate from a Vec<User>, put it in TableState,
and build the generated filters against that state. Store the table entity and
filter collection on the owning view:
use gpui_kit::component::table::{DataTable, TableState};
let delegate = UserTableDelegate::new(rows);
let table = cx.new(|cx| TableState::new(delegate, window, cx));
let filters = UserFilterEntities::build_for_table(table.clone(), cx);
let element = DataTable::new(&table)
.stripe(true)
.scrollbar_visible(true, true);
Keep the TableState entity on the owning view. Observe it when delegate
updates should rerender parent controls such as status bars or filter badges.
Render the entries returned by filters.filter_sidebar_data(cx) to make the
filter widgets visible; Typed filters shows that flow.
Verify the result
The table should display one row for each item passed to
UserTableDelegate::new. Clicking the name header should change the sort
order, and changing a rendered filter should narrow the visible rows without
replacing delegate.rows.
If the derive reports that a field does not implement TableCell, derive it on
an application value object or use a custom cell renderer. If rendering panics
because localization state is missing, run both initialization calls above
before creating or rendering the filters.