Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Columns and rows

Each non-skipped field becomes a column in source order. Attributes control the initial column configuration, while the generated delegate owns sorting and maps visible rows back to the source rows vector.

#[derive(Clone, gpui_table::GpuiTable)]
#[gpui_table(
    id = "build-history",
    context_menu_route = "/builds/{id}",
    context_menu_label = "Open build"
)]
struct BuildRow {
    #[gpui_table(skip, context_menu_id)]
    internal_id: u64,

    #[gpui_table(width = 220., sortable)]
    package: String,

    #[gpui_table(width = 100., resizable = false)]
    status: String,

    #[gpui_table(width = 140., movable = false, sortable, ascending)]
    started_at: jiff::Timestamp,
}

Common field options are:

OptionEffect
skipExcludes the field from generated columns
title = "Label"Overrides the displayed column label
col = "stable-key"Overrides the column key
width = 160.Sets the initial width; the default is 100.
sortableEnables delegate sorting for the field
ascending or descendingSelects the initial sort direction
fixed = "left" or "right"Pins the column to that side
text_rightRight-aligns cell text
resizable = false or movable = falseDisables that interaction
style = path::to_fnReplaces the default renderer for this field
sort_key = path::to_fnSupplies a typed optional calculated ordering key

ascending and descending cannot be combined. Initial directions also enable sorting. See Order rows and calculated keys for multiple keys, stable row identity, null placement and calculated keys.

Date and time cells

Built-in Jiff dates and times use localized ICU formatting. A bare jiff::Timestamp displays in the system timezone (the browser’s timezone on WebAssembly), while a jiff::ZonedDateTime displays in its own zone. Valid offsets outside ICU’s 18-hour range use the original Jiff representation. Date filters have a separate contract: civil and zoned datetimes retain their calendar date, and bare Jiff instants and SpacetimeDB timestamps match by UTC date.

Jiff civil years are limited to −9999 through 9999. A leap-second input with second 60 is interpreted by Jiff as second 59; it is not stored literally as 60. If the exact original text must be displayed, use DisplayCell<String> instead of a typed date or time cell. That text is not a typed date filter value.

Render application value objects

#[derive(TableCell)] delegates a single-field wrapper to the inner field’s existing renderer:

#[derive(Clone, gpui_table::TableCell)]
struct Revision(String);

Use #[table_cell(display)] only when the wrapper itself implements std::fmt::Display. Use #[table_cell(format = path::to::formatter)] when a function taking &Revision should produce its label. For a complete custom GPUI element, use the style hook described in Loading and custom cells.

Keep row visibility current

The generated delegate keeps source rows in delegate.rows. Its visible row view composes generated filters with an optional application-owned row scope. Call refresh_filtered_rows() after in-place row mutations that may change visibility.

The table ID defaults to the row type in snake case. Set #[gpui_table(id = "build-history")] when external tools or saved state need a stable value. Explicit IDs must be nonempty and contain only lowercase ASCII letters, digits, _, or -.

The example marks internal_id as the context-menu value and substitutes it for {id} in the route. context_menu_route requires either one field marked context_menu_id or the equivalent context_menu_row_id = "internal_id" struct option. Use context_menu_route_fn and context_menu_label_fn when routing or localization is owned by helper functions. Add custom_context_menu and implement TableRowContextMenu only when generated and application-owned menu items must be composed.