lazy_column

Function lazy_column 

Source
pub fn lazy_column<F>(args: LazyColumnArgs, state: LazyListState, configure: F)
where F: FnOnce(&mut LazyColumnScope<'_>),
Expand description

§lazy_column

A vertically scrolling list that only renders items visible in the viewport.

§Usage

Display a long, vertical list of items without incurring the performance cost of rendering every item at once.

§Parameters

  • args — configures the list’s layout and scrolling behavior; see LazyColumnArgs.
  • state — a clonable LazyListState to manage scroll position and item measurement caching.
  • configure — a closure that receives a LazyColumnScope for adding items to the list.

§Examples

// No Arc wrapper; `LazyListState` encapsulates internal Arc/RwLock state.
use tessera_ui_basic_components::{
    lazy_list::{lazy_column, LazyColumnArgs, LazyListState},
    text::{text, TextArgsBuilder},
};

let list_state = LazyListState::new();

lazy_column(LazyColumnArgs::default(), list_state, |scope| {
    scope.items(1000, |i| {
        let text_content = format!("Item #{}", i);
        text(TextArgsBuilder::default().text(text_content).build().unwrap());
    });
});