GPUI Box GitHub

Components / display

DescriptionList builder

A list of term and description pairs, in one or two columns.

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

use gpui_kit::display::description_list::DescriptionList;

Reviewed in detail.

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

Chain onto the value.

item(item: DescriptionItem) -> Self
items(items: impl IntoIterator<Item = DescriptionItem>) -> Self
columns(columns: usize) -> Self
on_copy(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
Example · detail
fn detail(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    stack(&theme)
        .w(px(640.0))
        .child(caption(
            &theme,
            "unknown, not applicable, and redacted are three facts",
        ))
        // The facts are a section of a detail page rather than prose loose on
        // the canvas, and the list is drawn the way a detail page would hold
        // it: on a surface with an edge the two columns are read against.
        .child(
            div()
                .column()
                .card_surface(&theme, CardVariant::Elevated)
                .p_token(&theme, Space::Md)
                .child(
            DescriptionList::new("scene.detail.facts")
                .columns(2)
                .items([
                    DescriptionItem::new("id", "Run", "run-4821"),
                    DescriptionItem::new("owner", "Owner", "fixture-owner"),
                    DescriptionItem::new("finished", "Finished", DescriptionValue::Unknown),
                    DescriptionItem::new("artifact", "Artifact", DescriptionValue::NotApplicable),
                    DescriptionItem::new(
                        "token",
                        "Access token",
                        DescriptionValue::redacted("51 characters"),
                    )
                    .copyable(true),
                ])
                .on_copy(|_, _, _| {}),
                ),
        )
        .child(caption(
            &theme,
            "what happened, in the words the host chose",
        ))
        .child(
            Timeline::new("scene.detail.activity")
                .group(
                    TimelineGroup::new("today", "Today")
                        .entry(
                            TimelineEntry::new("queued", "Run queued")
                                .time("09:12")
                                .actor("fixture-owner")
                                .tone(Tone::Neutral),
                        )
                        .entry(
                            TimelineEntry::new("started", "Indexing started")
                                .time("09:13")
                                .actor("scheduler")
                                .tone(Tone::Info),
                        )
                        .entry(
                            TimelineEntry::new("failed", "Indexing failed")
                                .time("09:41")
                                .actor("scheduler")
                                .tone(Tone::Danger)
                                .detail(crate::foundation::text(
                                    &theme,
                                    TypeScale::Body,
                                    SharedString::new_static(
                                        "The host refused the request. The refusal is shown as it \
                                     arrived.",
                                    ),
                                ).text_tone(&theme, TextTone::Muted)),
                        ),
                )
                .group(
                    TimelineGroup::new("earlier", "Earlier").entry(
                        TimelineEntry::new("imported", "Workspace imported")
                            .time_unknown()
                            .actor("fixture-owner")
                            .tone(Tone::Neutral),
                    ),
                ),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/display/description_list.rs