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.
Constructors
Properties
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
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.
public Label AutoWidth(string parentSelector = null, bool alignRight = false)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.
See also
- TextBlock – Base class for text rendering components.
- TextBox – An input control that can be paired with a Label for enhanced usability.