From 07ba7c8c44f2c6e611acfa5d96f8b717068bc5e4 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 25 Feb 2025 01:58:20 +0800 Subject: [PATCH] gpui: Add `underline` style method (#24784) Release Notes: - N/A Add a shorter method to apply underline style. https://tailwindcss.com/docs/text-decoration-line#underling-text --------- Co-authored-by: Marshall Bowers --- crates/gpui/src/styled.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/gpui/src/styled.rs b/crates/gpui/src/styled.rs index c1f6a9f61754c9ade5e92a680b5534dffdb06937..57951650c331fa21f858021905ae6d444532dd20 100644 --- a/crates/gpui/src/styled.rs +++ b/crates/gpui/src/styled.rs @@ -1,7 +1,7 @@ use crate::{ self as gpui, px, relative, rems, AbsoluteLength, AlignItems, CursorStyle, DefiniteLength, Fill, FlexDirection, FlexWrap, Font, FontStyle, FontWeight, Hsla, JustifyContent, Length, - SharedString, StrikethroughStyle, StyleRefinement, TextOverflow, WhiteSpace, + SharedString, StrikethroughStyle, StyleRefinement, TextOverflow, UnderlineStyle, WhiteSpace, }; use crate::{TextAlign, TextStyleRefinement}; pub use gpui_macros::{ @@ -486,6 +486,17 @@ pub trait Styled: Sized { self } + /// Sets the text decoration to underline. + /// [Docs](https://tailwindcss.com/docs/text-decoration-line#underling-text) + fn underline(mut self) -> Self { + let style = self.text_style().get_or_insert_with(Default::default); + style.underline = Some(UnderlineStyle { + thickness: px(1.), + ..Default::default() + }); + self + } + /// Sets the decoration of the text to have a line through it. /// [Docs](https://tailwindcss.com/docs/text-decoration#setting-the-text-decoration) fn line_through(mut self) -> Self {