diff --git a/crates/ui2/src/components/label.rs b/crates/ui2/src/components/label.rs index 7aeda3e850fbe91463f6f3f6a0298cb3fc7fa5a7..d455a041ee6e8f861a3cdacf1c155c2f7fc57871 100644 --- a/crates/ui2/src/components/label.rs +++ b/crates/ui2/src/components/label.rs @@ -129,6 +129,9 @@ impl RenderOnce for HighlightedLabel { )); } + let mut text_style = cx.text_style().clone(); + text_style.color = self.color.color(cx); + div() .flex() .when(self.strikethrough, |this| { @@ -146,7 +149,7 @@ impl RenderOnce for HighlightedLabel { LabelSize::Default => this.text_ui(), LabelSize::Small => this.text_ui_sm(), }) - .child(StyledText::new(self.label).with_highlights(&cx.text_style(), highlights)) + .child(StyledText::new(self.label).with_highlights(&text_style, highlights)) } } diff --git a/crates/ui2/src/components/stories/label.rs b/crates/ui2/src/components/stories/label.rs index 2417bee6e1cd77646ceddd2c4febe4c6e45b7e19..e026d388fde62545f47aab22985fa7efba4f3c7a 100644 --- a/crates/ui2/src/components/stories/label.rs +++ b/crates/ui2/src/components/stories/label.rs @@ -23,5 +23,9 @@ impl Render for LabelStory { "Héllo, world!", vec![0, 1, 3, 8, 9, 13], )) + .child(Story::label("Highlighted with `color`")) + .child( + HighlightedLabel::new("Hello, world!", vec![0, 1, 2, 7, 8, 12]).color(Color::Error), + ) } }