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

class

Label

public sealed class Label : TextBlock, ISpecialCaseStyling, IRoundedStyle

A non-interactive label component, typically used to caption form fields.

Namespace
Tesserae
Inheritance
TextBlock → Label
Implements
ISpecialCaseStyling, IRoundedStyle

Constructors

NameDescription
LabelInitializes a new instance of this class.
Constructor
Label
Overload
Label(string)Initializes a new instance of this class.
Label(IComponent)Initializes a new instance of this class.
Label(string)
public Label(string text = string.Empty)

Initializes a new instance of this class.

Parameters

text string
Label(IComponent)
public Label(IComponent component)

Initializes a new instance of this class.

Parameters

component IComponent

Properties

NameDescription
IsRequiredGets or sets a value indicating whether the component is required for form submission.
IsInlineReturns a value indicating whether the component is inline.
ContentSets the content rendered inside the surface.
Property
Label.IsRequired
public override bool IsRequired { get ; set ; }

Gets or sets a value indicating whether the component is required for form submission.

Property
Label.IsInline
public bool IsInline { get ; set ; }

Returns a value indicating whether the component is inline.

Property
Label.Content
public IComponent Content { set ; }

Sets the content rendered inside the surface.

Methods

NameDescription
SetContentSets the content of the component.
InlineRenders the component inline.
SetMinLabelWidthSets the min label width of the component.
WithContentMarginReturns the component configured with the given content margin.
AlignLabelTopAligns the label to the top of its container.
AutoWidthComputes the label width automatically from its sibling components so labels in a column line up.
Method
Label.SetContent
public Label SetContent(IComponent content)

Sets the content of the component.

Method
Label.Inline
public Label Inline()

Renders the component inline.

Method
Label.SetMinLabelWidth
public Label SetMinLabelWidth(UnitSize unitSize)

Sets the min label width of the component.

Method
Label.WithContentMargin
public Label WithContentMargin()

Returns the component configured with the given content margin.

Method
Label.AlignLabelTop
public Label AlignLabelTop()

Aligns the label to the top of its container.

Method
Label.AutoWidth
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.
AutoWidth(string, bool)
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.

Parameters

parentSelector string
alignRight bool
AutoWidth(IComponent, bool)
public Label AutoWidth(IComponent parentElement, bool alignRight = false)

Computes the label width automatically from its sibling components so labels in a column line up.

Parameters

parentElement IComponent
alignRight bool

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.
© 2026 Curiosity. All rights reserved.