diff --git a/crates/story/src/stories/button_story.rs b/crates/story/src/stories/button_story.rs index a977f72d8..fb68325f0 100644 --- a/crates/story/src/stories/button_story.rs +++ b/crates/story/src/stories/button_story.rs @@ -4,7 +4,8 @@ use gpui::{ }; use gpui_component::{ - ActiveTheme, Disableable as _, Icon, IconName, Selectable as _, Sizable as _, Theme, + ActiveTheme, Disableable as _, Icon, IconName, Selectable as _, Sizable as _, Size, StyleSized, + Theme, button::{Button, ButtonCustomVariant, ButtonGroup, ButtonVariants as _}, checkbox::Checkbox, h_flex, v_flex, @@ -906,5 +907,49 @@ impl Render for ButtonStory { .on_click(Self::on_click), ), ) + .child( + section("Button with different text size") + .child( + Button::new("button-custom-text-large") + .primary() + .label("Large") + .text_lg(), + ) + .child( + Button::new("button-custom-text-medium") + .primary() + .label("Medium") + .button_text_size(Size::Medium), + ) + .child( + Button::new("button-custom-text-small") + .primary() + .label("Small") + .text_sm(), + ) + .child( + Button::new("button-custom-text-xsmall") + .primary() + .label("XSmall") + .button_text_size(Size::XSmall), + ) + .child( + Button::new("button-custom-text-35") + .primary() + .label("35 px") + .button_text_size(Size::Size(px(35.0))), + ) + .child( + Button::new("button-custom-text-8") + .primary() + .label("8 px") + .text_size(px(8.0)), + ) + .child( + Button::new("button-custom-text-8") + .primary() + .label("Not Specified"), + ), + ) } } diff --git a/crates/ui/src/button/button.rs b/crates/ui/src/button/button.rs index 60d1266d6..9a0e77048 100644 --- a/crates/ui/src/button/button.rs +++ b/crates/ui/src/button/button.rs @@ -2,7 +2,7 @@ use std::rc::Rc; use crate::{ ActiveTheme, Colorize as _, Disableable, FocusableExt as _, Icon, IconName, Selectable, - Sizable, Size, StyleSized, StyledExt, h_flex, spinner::Spinner, tooltip::Tooltip, + Sizable, Size, StyledExt, h_flex, spinner::Spinner, tooltip::Tooltip, }; use gpui::{ Action, AnyElement, App, ClickEvent, Corners, Div, Edges, ElementId, Hsla, InteractiveElement, @@ -572,7 +572,6 @@ impl RenderOnce for Button { .w_full() .items_center() .justify_center() - .button_text_size(self.size) .map(|this| match self.size { Size::XSmall => this.gap_1(), Size::Small => this.gap_1(), diff --git a/crates/ui/src/styled.rs b/crates/ui/src/styled.rs index 93a4b0da0..953de007f 100644 --- a/crates/ui/src/styled.rs +++ b/crates/ui/src/styled.rs @@ -531,7 +531,9 @@ impl StyleSized for T { match size { Size::XSmall => self.text_xs(), Size::Small => self.text_sm(), - _ => self.text_base(), + Size::Medium => self.text_base(), + Size::Large => self.text_lg(), + Size::Size(size) => self.text_size(size), } } }