List
A virtual list of count rows of equal height. List::show declares the visible rows.
ui.listBasic
ui.list(1000).row_height(24).h(120).bordered().rounded_md().show(|ui, i| { ui.row().px(10).h_fill().children(|ui| { ui.text(format_args!("Row {i} of 1000")).text_sm(); });});Rows with several widgets
ui.list(1000).row_height(32).h(128).show(|ui, i| { ui.row().w_fill().px(8).gap(8).children(|ui| { ui.icon(IconName::File); ui.text(format_args!("File {i}")); ui.spacer(); ui.text(format_args!("{} KB", 4 + i)).text_sm().muted(); });});API reference
| Setting | Description |
|---|---|
.row_height(height: impl Length) | The row height in logical pixels. The default is the theme's row height. |
.w(width: impl Into<Sizing>) | The width; a plain length is a fixed width. |
.h(height: impl Into<Sizing>) | The height; a plain length is a fixed height. |
.h_fill() | Takes the remaining height. |
.fill() | Takes the remaining width and height. |
.bordered() | A 1 logical pixel border in the theme's border color. |
.rounded_md() | The theme's control radius. |
.style(style: Style) | Replaces the list's style with style. |
.show(row: impl FnMut(&mut Ui<'a>, usize)) | Places the list and returns its interaction result. row is called only for the visible rows, each keyed by its index. At any scroll position only one screen of rows is built, laid out and drawn. |