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.
InputLabel is also the property row of the design system: a horizontal InputLabel with an optional leading icon, a draggable label that scrubs the numeric fields it wraps, and capValue to keep long property names readable on wide panels. For a labelled numeric row with the scrub wired in and impossible to forget, use NumericPropertyFloat or NumericPropertyInt.
Examples
A property row with a leading icon and a scrubbable label.
<appui:InputLabel label="Opacity" icon="drop" draggable="true" cap-value="true">
<appui:FloatField value="1" low-value="0" high-value="1" />
</appui:InputLabel>
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
capValueUssClassName
The InputLabel styling class applied when the input is width-capped.
Declaration
public const string capValueUssClassName = "appui-inputlabel--cap-value"
Field Value
| Type | Description |
|---|---|
| string |
columnUssClassName
The styling class given to each child of the control cell while columns hands the cell out as columns.
Declaration
public const string columnUssClassName = "appui-inputlabel__column"
Field Value
| Type | Description |
|---|---|
| string |
columnsModeUssClassName
The InputLabel styling class prefix carrying the columns mode.
Declaration
public const string columnsModeUssClassName = "appui-inputlabel--columns-"
Field Value
| Type | Description |
|---|---|
| string |
columnsUssClassName
The InputLabel styling class applied while its control cell is handed to the children as columns, in either Even or Pair.
Declaration
public const string columnsUssClassName = "appui-inputlabel--columns"
Field Value
| Type | Description |
|---|---|
| string |
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 |
iconUssClassName
The InputLabel leading icon styling class.
Declaration
public const string iconUssClassName = "appui-inputlabel__icon"
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 |
pairLoneUssClassName
The InputLabel styling class applied while a Pair cell holds a single control, which then keeps to the first of the two tracks.
Declaration
public const string pairLoneUssClassName = "appui-inputlabel--columns-pair-lone"
Field Value
| Type | Description |
|---|---|
| string |
rowLayoutUssClassName
The InputLabel row layout styling class.
Declaration
public const string rowLayoutUssClassName = "appui-inputlabel--layout-"
Field Value
| Type | Description |
|---|---|
| string |
tallUssClassName
The InputLabel styling class applied to a grid row taller than one row.
Declaration
public const string tallUssClassName = "appui-inputlabel--tall"
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 |
withIconUssClassName
The InputLabel styling class applied when a leading icon is set.
Declaration
public const string withIconUssClassName = "appui-inputlabel--with-icon"
Field Value
| Type | Description |
|---|---|
| string |
Properties
capValue
Whether the input is width-capped so that the label takes the freed space.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool capValue { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Remarks
By default the label occupies a fixed fraction of the row
(--appui-inputlabel-label-size) and the input grows to fill the rest, so a wide
panel stretches the input and truncates a long label. With capValue the label
grows instead and the input is capped at --appui-inputlabel-input-max-size,
which keeps long property names readable. Only affects the horizontal direction.
columns
Grid layout only: how the control cell is handed to the children.
Declaration
[CreateProperty]
[UxmlAttribute]
public InputLabelColumns columns { get; set; }
Property Value
| Type | Description |
|---|---|
| InputLabelColumns |
Remarks
Even lays the children out in a row that shares the cell
evenly; a child that needs a bigger share sets its own flex-grow, the UI Toolkit
stand-in for a subgrid span. Pair splits the cell into
exactly two equal halves with the inspector grid gap between them, for a slider and its
number field, and the halves line up with the next pair row's.
The registry's PropertyField takes columns: boolean | 'pair'. Three states do
not fit a bool, so this is an enum.
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 |
icon
The name of an optional leading icon displayed before the label.
Declaration
[CreateProperty]
[UxmlAttribute]
public string icon { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Use it to mark a property row with a glyph, the way an inspector row does. Set it to
null or an empty string to remove the icon.
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 |
inputContainer
The container holding the input(s), between the label cell and the help text.
Declaration
public VisualElement inputContainer { get; }
Property Value
| Type | Description |
|---|---|
| VisualElement |
label
The label value.
Declaration
[CreateProperty]
[UxmlAttribute]
public string label { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
labelFor
The name of the control this row labels. Set it and a click on the
label operates that control, the way a click on an HTML <label for> toggles its
checkbox.
Declaration
[CreateProperty]
[UxmlAttribute]
public string labelFor { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
The control is looked up inside this row first, then anywhere in the panel, and must be IPressable: a Checkbox, a Toggle or a Radio, for instance. A disabled control is left alone.
Ignored while draggable is on, as the registry ignores labelFor while
scrub is active: a drag that ends on the label would otherwise toggle the control at
the end of every scrub, and a row only scrubs when its value is numeric, which is not a
control a label click operates anyway.
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 |
rowLayout
How the label and the control are laid out.
Declaration
[CreateProperty]
[UxmlAttribute]
public InputLabelRowLayout rowLayout { get; set; }
Property Value
| Type | Description |
|---|---|
| InputLabelRowLayout |
Remarks
Grid puts the row on the inspector column grid, which is what makes a stack of rows share one set of column edges. capValue has no effect there: the token columns already size both cells, and capping the control would move the column edge on that row alone.
A grid row keeps its leading icon inside the label cell rather than beside it, so the icon comes out of the label's share and the control still starts on the column edge.
tall
Grid layout only: a control taller than one row, a multi-line text area for instance. The row grows to fit it and aligns its cells to the top, so the label stays on the first line.
Declaration
[CreateProperty]
[UxmlAttribute]
public bool tall { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
Methods
GetColumnsUssClassName(InputLabelColumns)
Declaration
public static string GetColumnsUssClassName(InputLabelColumns enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| InputLabelColumns | enumValue |
Returns
| Type | Description |
|---|---|
| string |
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 |
GetRowLayoutUssClassName(InputLabelRowLayout)
Declaration
public static string GetRowLayoutUssClassName(InputLabelRowLayout enumValue)
Parameters
| Type | Name | Description |
|---|---|---|
| InputLabelRowLayout | enumValue |
Returns
| Type | Description |
|---|---|
| string |
RefreshColumnMarkers()
Re-tags the children of the control cell: the first one renders without a leading gap, and each one is styled as a column while columns is on.
Declaration
public void RefreshColumnMarkers()
Remarks
This runs on every layout pass of that cell and, while columns is on, whenever the children change. Call it directly only after mutating the children when the markers are needed before the next frame.