Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

VirtualTable

VirtualTable is a virtualized table optimized for large datasets.

When To Use It

Use VirtualTable when table datasets are large enough that rendering all rows at once is too expensive. It keeps UI performance stable by reusing row views and rendering only visible rows.

Constructing a VirtualTable

VirtualTable::new(cx, rows, columns, 32.0, |row: &RowData| row.id)
    .sort_state(sort_state)
    .resizable_columns(true)
    .selectable(Selectable::Single)
    .selected_row_ids(selected_ids)
    .on_sort(|cx, key, direction| {
        cx.emit(AppEvent::SortBy(key, direction));
    })
    .on_row_select(|cx, id| {
        cx.emit(AppEvent::SelectRow(id));
    });

item_height is required and should match your row layout height for smooth virtualization.

VirtualTable Modifiers

ModifierTypeDescriptionDefault
sort_stateimpl Res<Option<TableSortState<K>>>Controlled sort column + direction.None
resizable_columnsimpl Res<impl Into<bool>>Enables/disables column resize interactions globally.false
sort_cycleimpl Res<impl Into<TableSortCycle>>Header click sort behavior (BiState or TriState).BiState
selectableimpl Res<impl Into<Selectable>>Row selection mode.Selectable::None
selection_follows_focusimpl Res<impl Into<bool>>Select rows as focus moves.false
selected_row_idsimpl Res<[Id]>Controlled selected row IDs.empty
on_sortFn(&mut EventContext, K, TableSortDirection)Called when header requests sort change.-
on_row_selectFn(&mut EventContext, Id)Called when a row is selected.-

API Notes

  • Constructor: VirtualTable::new(cx, rows, columns, item_height, row_id)
  • Uses VirtualList internally for viewport-efficient row rendering.
  • Shares sort/selection patterns with Table.

Components and Styling

SelectorDescription
virtual-tableRoot virtual table element.
virtual-table .table-header-rowHeader row container.
virtual-table .table-header-cellHeader cell container.
virtual-table .table-header-titleHeader title label from TableHeader.
virtual-table .table-sort-indicatorSort indicator label from TableHeader.
virtual-table .table-bodyVirtualized body container.
virtual-table .table-rowRecycled row container.
virtual-table .table-row.odd / .evenAlternating row classes.
virtual-table .table-cellCell container.

Accessibility

  • Keep row identity stable via row_id so controlled selection remains consistent during virtualization.
  • Provide clear header labels and selection feedback when rows are recycled.