EditableLabel
Description
EditableLabel is a UI component that displays text which can be clicked to switch into an inline editing mode. In this mode, users can modify the text content interactively. It is ideal for scenarios where information should appear as static text by default but offer an editing interface upon interaction. EditableLabel is part of the Components group and combines display and input behaviors, providing a seamless inline editing experience.
Usage
Instantiate an EditableLabel using the Tesserae.UI static helper. You can optionally provide the initial text value. When the label is clicked, it transforms into an input element allowing the user to edit the text. A save callback can be registered with the OnSave method to handle saving the new content.
Below is a sample usage:
Public Properties
- Size
- Type: TextSize
- Gets or sets the text size for both the label and the input element. The size is applied by modifying the CSS classes.
- Weight
- Type: TextWeight
- Gets or sets the font weight for the displayed text. Adjusts CSS classes to change the weight.
- TextAlign
- Type: TextAlign
- Gets or sets the text alignment. Updates the class list of the input element.
- IsEditingMode
- Type: bool
- Gets or sets the editing mode status. When true, the component displays the input element; when false, it shows the label view.
API reference
public sealed class EditableLabel : ComponentBase<EditableLabel, HTMLInputElement>, ITextFormating, IObservableComponent<string>An inline-editable single-line text surface that toggles between a read-only label and a textbox on click.
Constructors
Properties
public TextSize Size { get ; set ; }Gets or sets the size of the component.
public TextWeight Weight { get ; set ; }Gets or sets the font weight of the component.
public TextAlign TextAlign { get ; set ; }Gets or sets the text alignment of the component.
Methods
public EditableLabel OnSave(SaveEditHandler onSave)Registers a callback invoked when the save event fires.
public override HTMLElement Render()Renders the component's root HTML element.
Samples
Basic EditableLabel Usage
The following sample demonstrates how to create an EditableLabel, configure its appearance, and register an OnSave callback to process user inputs.
See also
- TextBlock – For display-only text components.
- EditableArea – A related component for multi-line text editing.
- TextBox – Underlying input component used by EditableLabel.