Fix Label text_align again.

This commit is contained in:
Jason Lee 2024-07-24 19:01:43 +08:00
parent ed132ad55e
commit 4c81977639
2 changed files with 3 additions and 3 deletions

View file

@ -52,9 +52,8 @@ impl Render for CheckboxStory {
.child( .child(
section("Label", cx) section("Label", cx)
.child( .child(
h_flex() v_flex()
.w_full() .w_full()
.justify_between()
.gap_4() .gap_4()
.child(Label::new("Text align left")) .child(Label::new("Text align left"))
.child(Label::new("Text align center").text_center()) .child(Label::new("Text align center").text_center())

View file

@ -3,7 +3,7 @@ use gpui::{
Styled, WindowContext, Styled, WindowContext,
}; };
use crate::theme::ActiveTheme; use crate::{theme::ActiveTheme, StyledExt};
#[derive(Default)] #[derive(Default)]
pub enum TextAlign { pub enum TextAlign {
@ -88,6 +88,7 @@ impl RenderOnce for Label {
div().text_color(cx.theme().foreground).child( div().text_color(cx.theme().foreground).child(
self.base self.base
.h_flex()
.map(|this| match self.align { .map(|this| match self.align {
TextAlign::Left => this.justify_start(), TextAlign::Left => this.justify_start(),
TextAlign::Center => this.justify_center(), TextAlign::Center => this.justify_center(),