Label
Description
The Label component is used to provide a descriptive title or identifier for a UI element or group of elements. It is typically paired with input controls or other interactive components to inform users of their purpose. Being part of the Components group, this control offers various styling options such as inline display, auto-width based on content, and visual distinction for required fields.
Usage
The Label component is instantiated through the static helper method in the Tesserae.UI class. You can simply call Label() with either a text string or an IComponent (for a more complex inner content). Here’s an example of creating a basic label:
API reference
public sealed class Label : TextBlock, ISpecialCaseStyling, IRoundedStyleA non-interactive label component, typically used to caption form fields.
- Namespace
- Tesserae
- Inheritance
- TextBlock → Label
- Implements
- ISpecialCaseStyling, IRoundedStyle
Constructors
| Name | Description |
|---|---|
| Label | Initializes a new instance of this class. |
| Overload | |
|---|---|
| Label(string) | Initializes a new instance of this class. |
| Label(IComponent) | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| IsRequired | Gets or sets a value indicating whether the component is required for form submission. |
| IsInline | Returns a value indicating whether the component is inline. |
| Content | Sets the content rendered inside the surface. |
public override bool IsRequired { get ; set ; }Gets or sets a value indicating whether the component is required for form submission.
public bool IsInline { get ; set ; }Returns a value indicating whether the component is inline.
Methods
| Name | Description |
|---|---|
| SetContent | Sets the content of the component. |
| Inline | Renders the component inline. |
| SetMinLabelWidth | Sets the min label width of the component. |
| WithContentMargin | Returns the component configured with the given content margin. |
| AlignLabelTop | Aligns the label to the top of its container. |
| AutoWidth | Computes the label width automatically from its sibling components so labels in a column line up. |
public Label SetMinLabelWidth(UnitSize unitSize)Sets the min label width of the component.
public Label WithContentMargin()Returns the component configured with the given content margin.
| Overload | |
|---|---|
| AutoWidth(string, bool) | Computes the label width automatically from its sibling components so labels in a column line up. |
| AutoWidth(IComponent, bool) | Computes the label width automatically from its sibling components so labels in a column line up. |
Samples
Label Variants
The sample below demonstrates different usages of the Label component—simple text labels, disabled labels, and required labels—as well as labels with different styles (primary, secondary, tiny) and inline configurations with or without auto-width.