GPUI Box GitHub

Components / data

ImageList builder

A token-spaced image tile collection.

A builder is RenderOnce. Construct and mount it in one expression.

use gpui_kit::data::ImageList;

Reviewed in image-list.

Construct
new(ident: impl Into<Ident>) -> Self
Options

Chain onto the value.

items(items: impl IntoIterator<Item = ImageListItem>) -> Self
columns(columns: usize) -> Self
columns_at(breakpoint: Breakpoint, columns: usize) -> Self
gap(gap: Space) -> Self
selected(id: impl Into<SharedString>) -> Self
on_select(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
Example · image-list
fn image_list(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    let items = [
        ("native", "Native runtime", "Runtime"),
        ("gateway", "Remote gateway", "Gateway"),
        ("archive", "Archive models", "Archive"),
        ("preview", "Preview models", "Preview"),
        ("disabled", "Managed image", "Policy"),
    ];
    stack(&theme)
        .w(px(840.0))
        .child(caption(
            &theme,
            "Caller-owned media tiles reflow from two to four measured columns",
        ))
        .child(
            ImageList::new("scene.image-list")
                .columns(2)
                .columns_at(Breakpoint::Medium, 4)
                .selected("gateway")
                .items(items.into_iter().map(|(id, label, image)| {
                    ImageListItem::new(id, label, scene_picture(image, cx))
                        .disabled(id == "disabled")
                }))
                .on_select(|_, _, _| {}),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/data/image_list.rs