iced_table2
A feature-rich table widget for iced 0.14.
Features
- Synchronized scrolling -- Header, body, and optional footer stay horizontally aligned as the user scrolls.
- Interactive column resizing -- Drag column dividers to resize. Visual feedback highlights the divider on hover.
- Row selection -- Click rows to select them with visual highlighting.
- Header click / sorting -- Click column headers to trigger a callback, useful for implementing column sorting.
- Customizable styling -- Implement the
Catalogtrait to control header, footer, row, and divider appearance. A default theme with alternating row colors is provided out of the box.
Usage
Add the dependency to your Cargo.toml:
[]
= "0.14"
Quick start
- Define a column type that implements
iced_table2::table::Column. - Create
widget::Ids for the header, body, and (optionally) footer scrollables. - Call
iced_table2::table()to build the widget. - Handle the
on_syncmessage in yourupdatefunction by callingscrollable::scroll_toon the header and footer ids to keep them in sync with the body.
use widget;
use table;
// In your view function:
let header_id = unique;
let body_id = unique;
let table = table
.cell_padding
.min_width;
To enable column resizing, chain .on_column_resize(Message::ColumnDragged, Message::ColumnReleased) and store the resize offsets in your column type.
To enable row selection, chain .on_row_press(Message::RowPressed) and call .selected_row(index) to highlight the selected row.
To react to header clicks (e.g. for sorting), chain .on_header_press(Message::HeaderPressed) and handle the column index in your update function.
Examples
Run the examples from the repository root:
# Minimal table with 3 columns and 5 rows
# Full-featured table with column resizing, footer, row selection, and sorting
License
GPL-3.0