TextField

Build single-line input with keyboard traits, icons, submission, and accessories.

TextField is the single-line text input. Its Text property supports two-way binding for editable ViewModel state:

var email = new TextField
{
    Placeholder = "Email address",
    LeadingIcon = ImageSource.Symbol("envelope"),
    Keyboard = KeyboardType.Email,
    ContentKind = ContentKind.Email,
    Capitalization = Capitalization.None,
    Autocorrection = false,
    ReturnKey = ReturnKeyType.Next,
    Text = Bind(vm => vm.Email)
        .TwoWay((vm, val) => vm.Email = val)
};

LeadingIcon and TrailingIcon accept local symbol, bundle, or data image sources. The trailing icon shares its native slot with ClearButton; when both are set, the icon wins. Remote URLs are only supported in the full Image control.

Keyboard behavior

Keyboard traits are hints to iOS, not validation rules:

  • Keyboard chooses a suitable keyboard layout, such as email, URL, phone, or numeric input.
  • ContentKind identifies the semantic value so the system can offer appropriate autofill.
  • Capitalization and Autocorrection tune text entry behavior.
  • ReturnKey changes the return-key label.
  • RequiresText disables the return key while the field is empty.
  • KeyboardLook requests the default, light, or dark keyboard appearance.

Use SubmitCommand to handle the return key:

password.SubmitCommand = viewModel.SignInCommand;

Set SubmitCommandParameter when the command needs context beyond the field's bound text.

TextChanged is available for local, immediate reactions. Prefer binding for application state so programmatic updates and typed input follow the same path.

Clear buttons and accessories

ClearButton controls when the built-in clear button appears. Clearing keeps focus, updates Text, and invokes TextChanged.

KeyboardToolbar adds a native bar above the keyboard with a Done button and, depending on its value, previous and next controls. For a fully custom accessory, set KeyboardAccessory to a SkeleKit view. A custom accessory takes precedence over the toolbar and belongs to one field.

amount.KeyboardAccessory = new StackPanel
{
    Orientation = Orientation.Horizontal,
    Padding = 8,
    Children =
    {
        new Button { Text = "Apply", Command = viewModel.ApplyAmountCommand }
    }
};

Use SecureField for passwords and TextEditor for multi-line input. Binding modes and update triggers are covered in MVVM and binding.