Class InputLabel
A versatile label component for form inputs with support for required fields, help text, and various layout options.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
[UxmlElement]
public class InputLabel : BaseVisualElement, IEventHandler, IResolvedStyle, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IContextOverrideElement, IAdditionalDataHolder
Remarks
InputLabel is a specialized UI component designed to provide a consistent and accessible way to label form inputs. It combines a label with optional required field indicators and help text, making it ideal for form design and user input validation.
The component supports both horizontal and vertical layouts, customizable label overflow behavior, and different styles of required field indicators to match your design system needs.
Note: InputLabel is designed to work seamlessly with other form input components and follows accessibility best practices by maintaining proper label-input relationships.
Constructors
InputLabel()
Default constructor.
Declaration
public InputLabel()
InputLabel(string)
Constructor.
Declaration
public InputLabel(string label)
Parameters
| Type | Name | Description |
|---|---|---|
| string | label | The label value. |
Fields
containerUssClassName
The InputLabel container styling class.
Declaration
public const string containerUssClassName = "appui-inputlabel__container"
Field Value
| Type | Description |
|---|---|
| string |
draggingUssClassName
The InputLabel dragging styling class.
Declaration
public const string draggingUssClassName = "appui-inputlabel--dragging"
Field Value
| Type | Description |
|---|---|
| string |
fieldLabelUssClassName
The InputLabel field-label styling class.
Declaration
public const string fieldLabelUssClassName = "appui-inputlabel__field-label"
Field Value
| Type | Description |
|---|---|
| string |
helpTextUssClassName
The InputLabel help text styling class.
Declaration
public const string helpTextUssClassName = "appui-inputlabel__help-text"
Field Value
| Type | Description |
|---|---|
| string |
inputAlignmentUssClassName
The InputLabel input alignment styling class.
Declaration
public const string inputAlignmentUssClassName = "appui-inputlabel--input-alignment-"
Field Value
| Type | Description |
|---|---|
| string |
inputContainerUssClassName
The InputLabel input container styling class.
Declaration
public const string inputContainerUssClassName = "appui-inputlabel__input-container"
Field Value
| Type | Description |
|---|---|
| string |
labelContainerUssClassName
The InputLabel label container styling class.
Declaration
public const string labelContainerUssClassName = "appui-inputlabel__label-container"
Field Value
| Type | Description |
|---|---|
| string |
orientationUssClassName
The InputLabel direction styling class.
Declaration
public const string orientationUssClassName = "appui-inputlabel--"
Field Value
| Type | Description |
|---|---|
| string |
sizeUssClassName
The InputLabel size styling class.
Declaration
public const string sizeUssClassName = "appui-inputlabel--size-"
Field Value
| Type | Description |
|---|---|
| string |
ussClassName
The InputLabel main styling class.
Declaration
public const string ussClassName = "appui-inputlabel"
Field Value
| Type | Description |
|---|---|
| string |
withHelpTextUssClassName
The InputLabel with help text styling class.
Declaration
public const string withHelpTextUssClassName = "appui-inputlabel--with-help-text"
Field Value
| Type | Description |
|---|---|
| string |
Properties
contentContainer
The content container.
Declaration
public override VisualElement contentContainer { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
Overrides
direction
The orientation of the label.
Declaration
[CreateProperty]
[UxmlAttribute]
public Direction direction { get; set; }
Property Value
| Type | Description |
|---|---|
| Direction |
draggable
Whether the label is draggable to increment/decrement the value of child input fields.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool draggable { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
helpMessage
The error message to display.
Declaration
[CreateProperty]
[UxmlAttribute]
public string helpMessage { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
helpVariant
The variant of the HelpText.
Declaration
[CreateProperty]
[UxmlAttribute]
public HelpTextVariant helpVariant { get; set; }
Property Value
| Type | Description |
|---|---|
| HelpTextVariant |
indicatorType
The requirement indicator to display.
Declaration
[CreateProperty]
[UxmlAttribute]
public IndicatorType indicatorType { get; set; }
Property Value
| Type | Description |
|---|---|
| IndicatorType |
inputAlignment
The alignment of the input.
Declaration
[CreateProperty]
[UxmlAttribute]
public Align inputAlignment { get; set; }
Property Value
| Type | Description |
|---|---|
| Align |
label
The label value.
Declaration
[CreateProperty]
[UxmlAttribute]
public string label { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
labelOverflow
The text overflow mode.
Declaration
[CreateProperty]
[UxmlAttribute]
public TextOverflow labelOverflow { get; set; }
Property Value
| Type | Description |
|---|---|
| TextOverflow |
required
Whether the input is required or not in the form. This will add an asterisk next to the label.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool required { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
requiredText
The requirement indicator to display.
Declaration
[CreateProperty]
[UxmlAttribute]
public string requiredText { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
GetInputAlignmentUssClassName(Align)
Declaration
public static string GetInputAlignmentUssClassName(Align enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Align | enumValue |
Returns
| Type | Description |
|---|---|
| string |
GetOrientationUssClassName(Direction)
Declaration
public static string GetOrientationUssClassName(Direction enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| Direction | enumValue |
Returns
| Type | Description |
|---|---|
| string |