diff --git a/crates/story/src/text_story.rs b/crates/story/src/text_story.rs index 905d7ffc..233c609d 100644 --- a/crates/story/src/text_story.rs +++ b/crates/story/src/text_story.rs @@ -66,14 +66,12 @@ impl Render for TextStory { .child( Label::new("Font Size Label") .text_size(px(20.)) - .text_left() .font_semibold() .line_height(rems(1.8)), ) .child( div().w(px(200.)).child( Label::new("Label should support text wrap in default, if the text is too long, it should wrap to the next line.") - .text_left() .line_height(rems(1.8)), ), ) diff --git a/crates/ui/src/label.rs b/crates/ui/src/label.rs index 59efe19e..2603e0ee 100644 --- a/crates/ui/src/label.rs +++ b/crates/ui/src/label.rs @@ -5,7 +5,7 @@ use gpui::{ use crate::{h_flex, theme::ActiveTheme}; -#[derive(Default)] +#[derive(Default, PartialEq, Eq)] pub enum TextAlign { #[default] Left, @@ -93,7 +93,13 @@ impl RenderOnce for Label { TextAlign::Center => this.justify_center(), TextAlign::Right => this.justify_end(), }) - .child(text_display), + .map(|this| { + if self.align == TextAlign::Left { + this.child(div().size_full().child(text_display)) + } else { + this.child(text_display) + } + }), ) } }