Table of Contents

Method TextField

Namespace
Velvet
Assembly
Velvet.Docs.dll

TextField(string?, string?, Action<string>?, string?, string?, string?, bool?, bool?, Func<VisualElement, Action>?, string?, string?, string?, IReadOnlyDictionary<string, string>?, IReadOnlyDictionary<string, string>?, string?, int?, bool?, bool?)

Creates a TextField.

public static ElementNode TextField(string? className = null, string? value = null, Action<string>? onValueChanged = null, string? key = null, string? name = null, string? label = null, bool? isPasswordField = null, bool? enabled = null, Func<VisualElement, Action>? refCallback = null, string? whileHoverClass = null, string? whileTapClass = null, string? whileFocusClass = null, IReadOnlyDictionary<string, string>? data = null, IReadOnlyDictionary<string, string>? aria = null, string? placeholder = null, int? maxLength = null, bool? isReadOnly = null, bool? isDelayed = null)

Parameters

className string

CSS-like utility class string. Multiple classes separated by spaces.

value string

Current text value (controlled).

onValueChanged Action<string>

Handler invoked when the input text changes.

key string

Key used to disambiguate siblings at the same position.

name string

Element name assigned to UnityEngine.UIElements.VisualElement.name for query/debug.

label string

Label text shown next to the field.

isPasswordField bool?

When true, masks the input as a password field.

enabled bool?

When false, disables user input.

refCallback Func<VisualElement, Action>

Callback invoked on mount with the created VisualElement; returned Action runs on unmount.

whileHoverClass string

USS class toggled while the pointer hovers the element.

whileTapClass string

USS class toggled while the pointer is pressed on the element.

whileFocusClass string

USS class toggled while the element holds keyboard/UI focus.

data IReadOnlyDictionary<string, string>

data-* attribute map matched by data-[...] variants.

aria IReadOnlyDictionary<string, string>

aria-* attribute map matched by aria-[...] variants.

placeholder string

A short hint shown in the empty field (HTML placeholder). An empty string declares an empty hint.

maxLength int?

Maximum number of characters the field accepts, -1 for no limit (HTML maxlength).

isReadOnly bool?

When true, the field cannot be edited (HTML readonly).

isDelayed bool?

When true, the value is not updated per keystroke but on Enter, on the field losing focus, and on a later render taking the flag off.

Returns

ElementNode

The created ElementNode representing this text field.

Remarks

placeholder, maxLength, isReadOnly and isDelayed are undeclared when null rather than reset to a default; Documentation~/react-migration.md owns what a null and a dropped one each do.