GPUI Box GitHub

Components / display

StatusLine builder

A dot plus a short label, for inline state.

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

use gpui_kit::display::status::StatusLine;

Reviewed in status.

Construct
new(label: impl Into<SharedString>, tone: Tone) -> Self
Options

Chain onto the value.

id(ident: impl Into<Ident>) -> Self
tint(tint: Hsla) -> Self
busy(ident: impl Into<Ident>) -> Self
activity(activity: motion::Activity) -> Self
Example · status
fn status(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    // A dot on its own says a thing has a state without saying which; the
    // name beside it is what the row is for.
    let named = |label: &'static str, dot: StatusDot| {
        div()
            .row()
            .items_center()
            .gap(px(theme.space(Space::Xs)))
            .child(dot)
            .child(caption(&theme, label))
    };
    stack(&theme)
        .w(px(560.0))
        .child(caption(&theme, "The smallest mark, and what each one claims"))
        .child(
            row(&theme)
                .gap(px(theme.space(Space::Lg)))
                .child(named("ready", StatusDot::new(Tone::Success)))
                .child(named("stale", StatusDot::new(Tone::Warning)))
                .child(named("refused", StatusDot::new(Tone::Danger)))
                .child(named("off", StatusDot::new(Tone::Neutral)))
                // The same dot wearing an identity colour: a state the six
                // severities cannot name, still reporting the severity it
                // claims through the surface around it.
                .child(named(
                    "Ada",
                    StatusDot::new(Tone::Neutral).tint(identity_tint(&theme, "agent.external")),
                )),
        )
        .child(caption(&theme, "Work that is still going"))
        .child(
            row(&theme)
                .child(
                    StatusDot::new(Tone::Accent)
                        .busy("scene.status.deliberating")
                        .activity(crate::motion::Activity::Deliberating),
                )
                .child(
                    StatusDot::new(Tone::Info)
                        .busy("scene.status.working")
                        .activity(crate::motion::Activity::Working),
                )
                .child(
                    StatusDot::new(Tone::Success)
                        .busy("scene.status.advancing")
                        .activity(crate::motion::Activity::Advancing),
                ),
        )
        .child(caption(&theme, "The same claim, named"))
        .child(
            StatusLine::new("Connected", Tone::Success).id("scene.status.line"),
        )
        .child(
            StatusLine::new("Ada · reviewing", Tone::Neutral)
                .tint(identity_tint(&theme, "agent.external"))
                .busy("scene.status.tinted")
                .id("scene.status.tinted"),
        )
        .child(caption(
            &theme,
            "A report: a wash and a glyph carry the severity, so two of them differ \
             by meaning and never by weight",
        ))
        .child(
            Callout::new(
                "The host refused this action. The refusal is shown, not converted to an empty state.",
                Tone::Danger,
            )
            .id("scene.status.refusal"),
        )
        .child(
            Callout::new("Refreshing failed. The last verified value remains visible.", Tone::Warning)
                .id("scene.status.stale"),
        )
        .into_any_element()
}

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