ltk

Function grid_min_cell

Source
pub fn grid_min_cell<Msg: Clone>(
    min_cell_width: impl Into<Length>,
) -> WrapGrid<Msg>
Expand description

Create an adaptive grid: the column count is derived at layout time from the available width, fitting as many columns as possible while keeping every cell at least min_cell_width wide (never fewer than one). Cells then share the width equally, so they range between min_cell_width and just under twice it — cap the count with max_columns to let cells grow instead on very wide surfaces.

Accepts logical f32 pixels or any Length (e.g. Length::fluid( 96.0 ) for a threshold that scales with the surface).

scroll(
    grid_min_cell( 96.0 )
        .max_columns( 8 )
        .spacing( 12.0 )
        .push( icon_button( data, w, h ).on_press( Msg::Open( 0 ) ) )
        // ...
)
.into()