Skip to main content

kitchen_ui/widgets/
row.rs

1//! The labelled row.
2
3use gpui_kit::component::h_flex;
4use gpui_kit::{IntoElement, ParentElement as _, SharedString, Styled as _, div, px};
5
6use crate::theme::{self, color};
7
8/// `label    control` on one line when both fit: the label [`theme::LABEL_W`] wide, the control
9/// the rest (at least [`theme::CONTROL_MIN_W`]). In a narrow panel the control drops under its
10/// label, full width. Nothing is clipped (a cut label names nothing): a long label wraps, a long
11/// value in a control ends in "…".
12pub fn row(label: impl Into<SharedString>, control: impl IntoElement) -> impl IntoElement {
13    h_flex()
14        .w_full()
15        .flex_wrap()
16        .gap(px(theme::SM))
17        .child(div().flex_none().w(px(theme::LABEL_W)).text_sm().text_color(color::text_muted()).child(label.into()))
18        .child(h_flex().flex_1().min_w(px(theme::CONTROL_MIN_W)).justify_end().child(control))
19}