HorizontalSeparator
Description
The HorizontalSeparator component is used to visually separate content into distinct groups with a horizontal rule. It can display text or custom content (such as an icon combined with text) within the separator. By default, the content is center-aligned, but you can adjust the alignment to Left or Right. This component is ideal for breaking up sections within a UI and enhancing visual organization.
Usage
Instantiate a HorizontalSeparator using the Tesserae.UI helper method. You can provide a string as default text or pass a custom component as its content. Additionally, use method chaining to control alignment and styling.
API reference
public class HorizontalSeparator : IComponent, IHasBackgroundColorA thin horizontal divider used to separate sections of a vertically stacked layout.
Constructors
public HorizontalSeparator(string text = string.Empty)Initializes a new instance of this class.
Properties
public Align Alignment { get ; set ; }Gets or sets the alignment.
public string Text { get ; set ; }Gets or sets the text shown in the component.
Methods
public HorizontalSeparator SetContent(IComponent component)Sets the content of the component.
public HorizontalSeparator Primary()Styles the component using the primary tone.
public HorizontalSeparator SetText(string text)Sets the text of the component.
public HTMLElement Render()Renders the component's root HTML element.
public HorizontalSeparator Left()Aligns the content of the component to the left.
public HorizontalSeparator Center()Centers the content of the component.
Samples
Basic Separators
The following sample demonstrates creating horizontal separators with various alignments and both text and custom content.