- Docs
- enzUI framework
- Developers
Lists and tables
Virtualised lists, grids and tables, trees, reorderable and keyed lists, and the scroll offset round trip they rely on.
Collections in enzUI split into two kinds. The virtualised members (virtual_list, virtual_grid, table, chat_list) build only the rows in view, so they are what you want past a few hundred items. The row widgets (list_row_surface, preview_row, sidebar_row, table_header_cell, table_text_cell) are the cells you put inside them.
See every widget in the widget catalog.

The scroll offset round trip
Virtualised widgets realise rows from a scroll offset the application owns. The widget reports wheel and scrollbar movement through a callback, update stores the new offset, and the next view passes it back. If you skip the round trip, the widget keeps realising the first rows whatever the user scrolls to. A few catalog entries carry a Wiring: note in the repository's docs/widgets.md for exactly this kind of requirement.
Tables
enz_table is a bounded, two-dimensional virtualised data grid. This pattern uses a caller-owned offset for row selection and scrolling.
let table = enz_table(
&self.model,
HeightModel::new(ROWS as usize, ROW_HEIGHT),
VariableHeightModel::new(self.widths),
|_row, _column, value: &String| enz_table_text_cell(value.clone()).into_element(),
)
.header(move |index, key| {
let active = sort.as_ref().filter(|(column, _)| column == key);
enz_table_header_cell(COLUMNS[index].1)
.sortable(true)
.sort_active(active.is_some())
.sort_ascending(active.is_some_and(|(_, d)| *d == SortDirection::Ascending))
.into_element()
})
.width(Length::Fill)
.height(Length::Fill)
.scroll_y(self.offset)
.on_scroll(|_dx, dy| Message::Scroll(dy))
.on_scroll_to(Message::ScrollTo)
.viewport_state(&self.viewport)
.on_column_sort(Message::Sort)
.on_column_resize(Message::Resize)
.sort_state(self.sort.clone())
.row_selection(move |row| Some(row) == selected)
.on_row_activate(|row| (format!("Row {}", row + 1), Message::Select(row)))
.into_element();The model implements enzui_core::table::TableProvider. The table keeps no column widths or sort order of its own; they live in the app state:
fn update(&mut self, message: Message) -> Task<Message> {
match message {
// The wheel reports a delta; the caller integrates and clamps it.
Message::Scroll(dy) => self.offset = (self.offset - dy).clamp(0.0, self.max_offset()),
Message::ScrollTo(y) => self.offset = y.clamp(0.0, self.max_offset()),
Message::Sort(command) => {
self.model.sort(command.column.as_str(), command.direction);
self.sort = Some((command.column, command.direction));
}
Message::Select(row) => self.selected = Some(row),
Message::Resize(resize) => self.widths[resize.column] = resize.width,
}
Task::none()
}TableViewportState publishes the effective viewport (viewport.resolved() gives the body height) so update can clamp the offset and navigate. Drag a header's right edge to resize its column; double-click the edge to fit the column to its contents. Tables also accept header_gap to separate row paint from the header divider.
Virtual lists and grids
enz_virtual_list (fixed heights) and enz_virtual_list_variable build rows from a viewport height, scroll offset and overscan (five items per side by default). Supply a .viewport_height(..) that matches layout, pass .scroll_offset(..) back from .on_scroll(..), and give rows stable keys so their state survives index changes. For rows whose height you only know after layout, .on_measure(..) with enz_row_measure reports a row's intrinsic height so the list can correct its estimate.
enz_virtual_grid is the spatial version for photo, icon and file-thumbnail collections. enz_chat_list is a variable-height virtual transcript; it has no self-scrolling mode, so the on_scroll to .scroll_offset(..) round trip is the only route. enz_chat_transcript is the presentational, non-virtualised column for shorter conversations.
Trees
enz_tree_view renders a keyboard-navigable tree from a host-owned, pre-flattened row list. The host rebuilds rows after expansion changes and handles selection and toggle requests. The tree is one Tab stop: arrows move between rows, Home and End reach the ends, Left and Right collapse, expand or move to a parent or child, and Enter or Space activates. Set .viewport_height(..) to realise only visible rows, and feed .on_scroll(..) back into .scroll_offset(..). In a right-to-left locale the tree indents from the right and Left expands.
Keyed and reorderable lists
keyed_columnreconciles children by key instead of slot, so a row keeps its state (focus, hover, a streaming caret) when rows are inserted or removed above it.keyed_column(rows).animate_moves()slides the rows a change moves to their new places on a spring, with exact layout on every frame; pair it withmotion::animated(..).enters_from(..)for an arriving row.enz_reorder_listis a keyed list with drag-to-reorder. Clickable rows opt in with.drag_through_children(true); composite rows drag by a part wrapped inreorder_handlewith.drag_handles(true). Releases publish a stable-idDropRequest;updateapplies it..horizontal()lays the list out in a row. Thereorder_groupsexample reorders sidebar groups by their headers.enz_drag_drop_hostowns one drag session across several collections. See Drag and drop.
Other collection widgets
| Widget | Use |
|---|---|
enz_file_browser | A host-owned listing with per-type icons and natural sort, ordered with the LC_COLLATE locale's collator |
enz_list_row_surface | A focusable, keyboard-activatable row with hover, pressed, selected and disabled states; .on_context(..) reports right-clicks |
enz_preview_row | Title, trailing text, excerpt and footer (a mail or note list) |
enz_shortcut_list | Sectioned keyboard-shortcut rows |
enz_download_list | The view over the core download model |
enz_schedule | A day or week time grid |
enz_carousel | Keyed paging with indicators, previous and next buttons, keyboard paging and optional swipe |
print_pdf | Lays headings, paragraphs and images out on pages and writes a vector PDF |
Choosing a list
| You have | Use |
|---|---|
| A short, static list | enz_vstack or keyed_column with row widgets |
| Rows that change order or arrive over time | keyed_column, optionally with .animate_moves() |
| Hundreds of rows or more | enz_virtual_list |
| Columns of data | enz_table |
| Thumbnails | enz_virtual_grid |
| A conversation | enz_chat_list (long) or enz_chat_transcript (short) |
| A hierarchy | enz_tree_view |
| A user-defined order | enz_reorder_list |