diff --git a/crates/ui-patterns/src/patterns/preferences/model.rs b/crates/ui-patterns/src/patterns/preferences/model.rs index 944993fa5a..dd729063ef 100644 --- a/crates/ui-patterns/src/patterns/preferences/model.rs +++ b/crates/ui-patterns/src/patterns/preferences/model.rs @@ -126,6 +126,8 @@ pub struct RowSpec<'a> { /// default a drop-down, and on a card ([`PreferencesLayout::Cards`](super::PreferencesLayout::Cards)) a short /// choice of up to five options is segmented. Ignored by other kinds. pub pills: Option, + /// A [`RowKind::Text`] row: the translated text shown while the field is empty. Ignored by other kinds. + pub placeholder: Option<&'a str>, /// The control and the value it shows. pub kind: RowKind<'a>, } @@ -133,7 +135,7 @@ pub struct RowSpec<'a> { impl<'a> RowSpec<'a> { /// A visible, enabled row with no keywords or help. pub fn new(key: &'a str, label: &'a str, kind: RowKind<'a>) -> Self { - Self { key, label, keywords: "", help: None, visible: true, enabled: true, step: None, pills: None, kind } + Self { key, label, keywords: "", help: None, visible: true, enabled: true, step: None, pills: None, placeholder: None, kind } } /// Sets extra search text for the row. @@ -171,6 +173,13 @@ impl<'a> RowSpec<'a> { self } + /// Sets the text a [`RowKind::Text`] row shows while empty. + #[must_use] + pub fn placeholder(mut self, placeholder: &'a str) -> Self { + self.placeholder = Some(placeholder); + self + } + /// Sets the step of a [`RowKind::Float`] row. #[must_use] pub fn step(mut self, step: f64) -> Self { diff --git a/crates/ui-patterns/src/patterns/preferences/rows.rs b/crates/ui-patterns/src/patterns/preferences/rows.rs index 82c66c8ec2..700848cb2e 100644 --- a/crates/ui-patterns/src/patterns/preferences/rows.rs +++ b/crates/ui-patterns/src/patterns/preferences/rows.rs @@ -39,7 +39,7 @@ pub(super) enum Kind { Int { value: i64, range: RangeInclusive, unit: Option, unit_text: Option