GPUI Box GitHub

Components / controls

FilterBar builder

A row of active conditions, a way to add one, a clear-all, and the count.

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

use gpui_kit::controls::filter_bar::FilterBar;

Reviewed in filter-bar.

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

Chain onto the value.

condition(condition: FilterCondition) -> Self
conditions(conditions: impl IntoIterator<Item = FilterCondition>) -> Self
count(count: ResultCount) -> Self
noun(noun: impl Into<SharedString>) -> Self
add_control(control: impl IntoElement) -> Self
add_label(label: impl Into<SharedString>) -> Self
clear_label(label: impl Into<SharedString>) -> Self
on_add(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
on_remove(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
on_clear(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
Example · filter-bar
fn filter_bar(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    stack(&theme)
        .w(px(720.0))
        .child(
            FilterBar::new("scene.filter-bar.runs")
                .conditions([
                    FilterCondition::new("status", "Status", "is", "failed"),
                    FilterCondition::new("owner", "Owner", "is", "fixture-owner"),
                    FilterCondition::new("started", "Started", "after", "09:00"),
                ])
                .count(ResultCount::Known(14))
                .noun("runs")
                .on_add(|_, _| {})
                .on_remove(|_, _, _| {})
                .on_clear(|_, _| {}),
        )
        .child(caption(&theme, "counting is not zero"))
        .child(
            FilterBar::new("scene.filter-bar.counting")
                .conditions([FilterCondition::new("status", "Status", "is", "queued")])
                .count(ResultCount::Counting)
                .on_add(|_, _| {})
                .on_remove(|_, _, _| {})
                .on_clear(|_, _| {}),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/controls/filter_bar.rs