Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add label docs
Nate Butler7dbe0519ece2
diff --git a/crates/ui/src/components/button/button.rs b/crates/ui/src/components/button/button.rsindex d3d33265440..b65bf050eb8 100644--- a/crates/ui/src/components/button/button.rs+++ b/crates/ui/src/components/button/button.rs@@ -7,7 +7,7 @@ use crate::{use super::button_icon::ButtonIcon;-/// [Button] can be use to create a button with a label and an optional icon.+/// An element that creates a button with a label and an optional icon.////// Common buttons:/// - Label, Icon + Label: [Button] (this component)@@ -19,7 +19,8 @@ use super::button_icon::ButtonIcon;////// # Examples///-/// A button with a label only:+/// **A button with a label**, is typically used in scenarios such as a form, where the button's label+/// indicates what action will be performed when the button is clicked.////// ```/// Button::new("button_id", "Click me!")diff --git a/crates/ui/src/components/label/label.rs b/crates/ui/src/components/label/label.rsindex 61f463a531b..7f092883ac6 100644--- a/crates/ui/src/components/label/label.rs+++ b/crates/ui/src/components/label/label.rs@@ -2,6 +2,28 @@ use gpui::WindowContext;use crate::{prelude::*, LabelCommon, LabelLike, LabelSize, LineHeightStyle};+/// A struct representing a label element in the UI.+///+/// The `Label` struct stores the label text and common properties for a label element.+/// It provides methods for modifying these properties.+///+/// # Examples+///+/// ```+/// Label::new("Hello, World!")+/// ```+///+/// **A colored label**, for example labeling a dangerous action:+///+/// ```+/// let my_label = Label::new("Delete").color(Color::Error);+/// ```+///+/// **A label with a strikethrough**, for example labeling something that has been deleted:+///+/// ```+/// let my_label = Label::new("Deleted").strikethrough(true);+/// ```#[derive(IntoElement)]pub struct Label {base: LabelLike,@@ -9,6 +31,13 @@ pub struct Label {}impl Label {+ /// Create a new `Label` with the given text.+ ///+ /// # Examples+ ///+ /// ```+ /// let my_label = Label::new("Hello, World!");+ /// ```pub fn new(label: impl Into<SharedString>) -> Self {Self {base: LabelLike::new(),@@ -18,26 +47,53 @@ impl Label {}impl LabelCommon for Label {+ /// Sets the size of the label using a [LabelSize].+ ///+ /// # Examples+ ///+ /// ```+ /// let my_label = Label::new("Hello, World!").size(LabelSize::Large);+ /// ```fn size(mut self, size: LabelSize) -> Self {self.base = self.base.size(size);self}+ /// Sets the line height style of the label using a [LineHeightStyle].+ ///+ /// # Examples+ ///+ /// ```+ /// let my_label = Label::new("Hello, World!").line_height_style(LineHeightStyle::Normal);+ /// ```fn line_height_style(mut self, line_height_style: LineHeightStyle) -> Self {self.base = self.base.line_height_style(line_height_style);self}+ /// Sets the color of the label using a [Color].+ ///+ /// # Examples+ ///+ /// ```+ /// let my_label = Label::new("Hello, World!").color(Color::Primary);+ /// ```fn color(mut self, color: Color) -> Self {self.base = self.base.color(color);self}+ /// Sets the strikethrough property of the label.+ ///+ /// # Examples+ ///+ /// ```+ /// let my_label = Label::new("Hello, World!").strikethrough(true);+ /// ```fn strikethrough(mut self, strikethrough: bool) -> Self {self.base = self.base.strikethrough(strikethrough);self}-}impl RenderOnce for Label {fn render(self, _cx: &mut WindowContext) -> impl IntoElement {