DataTable

DataTable is for records people need to compare across the same columns: files, users, invoices, runs, and similar data.
Use a table when scanning fields matters more than the looser feel of a list or card grid.

Example

use fission::prelude::*;
use std::sync::Arc;

fission_component! {
    pub BuildRunsTable<()> {
        props {
            rows: Vec<TableRow>,
            selected: Vec<String>,
            toggle_run: Arc<dyn Fn(String) -> ActionEnvelope + Send + Sync>,
            select_all: ActionEnvelope,
        }
    }

    view(table, _state, cx) =>
        DataTable(
            id: WidgetId::explicit("build-runs"),
            columns: vec![
                TableColumn {
                    id: "status".into(),
                    title: cx.tr("build.status"),
                    ..Default::default()
                },
                TableColumn {
                    id: "branch".into(),
                    title: cx.tr("build.branch"),
                    ..Default::default()
                },
            ],
            rows: table.rows.clone(),
            selected_ids: table.selected.clone(),
            on_selection_change: table.toggle_run.clone(),
            on_select_all: table.select_all.clone(),
            label: Some(cx.tr("build.runs")),
        )
}
The parent formats real build records into TableRow values in status/branch order and supplies registered selection actions. An empty query produces no rows, not a fake passing build. These headers are deliberately not sortable; add an on_sort action and current sort direction when the parent actually implements sorting.
Here the table is responsible for presentation. The reducer is responsible for which rows are selected and what selection means.

Field table

Field
Type
Meaning
Notes / default behavior
id
WidgetId
Stable identity for the table instance.
Used by retained interaction; Compose supplies component-relative identity.
columns
Vec<TableColumn>
Column definitions in display order.
Required. Width comes from the column records.
rows
Vec<TableRow>
Row data in display order.
Required. Each row's cells are matched to columns by index.
selection_mode
DataTableSelectionMode
Read-only or multiple controlled selection.
Use None to omit selection controls; default is Multiple.
selected_ids
Vec<String>
Currently selected row ids.
Controlled by app state.
on_selection_change
Option<Arc<dyn Fn(String) -> ActionEnvelope + Send + Sync>>
Closure that builds the action for row or checkbox selection.
Called with the row id.
on_select_all
Option<ActionEnvelope>
Action dispatched by the header checkbox.
The checkbox is disabled when no action is supplied.
label
Option<String>
Accessible name for the table.
Recommended when surrounding context does not already name the table.

How to think about tabular data here

A table works when every row shares the same shape and when columns matter more than custom per-row layout. The checked-in DataTable is intentionally simple: cells are plain strings, not arbitrary widgets. That keeps comparison easy, but it also means complex media cells, nested controls, or heavily formatted content usually want a custom table layout instead.
Selection is explicit. The widget highlights rows whose ids appear in selected_ids, and it uses the same selection callback for row presses and row checkboxes.

Current behavior and limits

The application owns sorting and bulk-selection state. Supply TableColumn::on_sort for sortable headers and DataTable::on_select_all for the header checkbox; an unavailable action renders its affordance disabled. The header surface fills the table width even when the declared columns use less space, while header and body cells retain the same explicit column widths.

Specific advice

Keep column counts modest on narrow screens. If comparison is still important on mobile, consider a smaller table with fewer columns plus a drill-in detail view instead of forcing a huge horizontal matrix.

Production checklist

•
Verify every row has the same cell count and order as the column definitions.
•
Test select-all against the intended scope: visible page, filtered results, or the full query.
•
Use stable record ids so sorting cannot transfer selection to another build.
Previous
Code