For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/elements/input.md.

<input>

A single-line text field, like <input type="text">. For several lines, use <textarea>.

Usage

src/app/search.ts
import { Component, signal } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-search',
  imports: [LYNX_ELEMENTS],
  template: `
    <input
      placeholder="Search"
      confirm-type="search"
      (bindinput)="query.set($event.detail.value)"
      (bindconfirm)="search()"
    />
  `,
})
export class Search {
  readonly query = signal('');

  search(): void {}
}

Import LYNX_ELEMENTS in your component (see Elements).

Lynx draws a field with no border, as tall as its text. Size and outline it with classes, such as class="h-10 rounded-lg border border-zinc-200 px-3", or with style.

Warning

Needs XElement in custom native apps (see Embedding).

Attributes

AttributeTypeDefaultDescription
type'text' | 'number' | 'digit' | 'password' | 'tel' | 'email''text'What can be typed, and which on-screen keyboard opens.
placeholderstring—Hint shown while the field is empty.
valuestring—The text the field shows, from its first render and whenever code changes it, such as to clear the field. Bind it as [value]: see Bind the value.
default-valuestring—iOS and Android. Text on the first render only. It doesn't fire bindinput.
maxlengthnumberNo limitMaximum number of characters.
confirm-type'send' | 'search' | 'go' | 'done' | 'next''send'Label of the keyboard's return key. Pressing it fires bindconfirm.
readonlybooleanfalseThe text can't be edited. How focus behaves differs between platforms.
disabledbooleanfalseThe field is fully inert: no focus and no keyboard.
input-filterstring—A regular expression each typed character must match, e.g. '[0-9]'.
show-soft-input-on-focusbooleantrueiOS and Android. Opens the on-screen keyboard when the field gets focus.
ios-auto-correctbooleantrueiOS only. Autocorrect.
ios-spell-checkbooleantrueiOS only. Spell checking.
android-fullscreen-modebooleantrueAndroid only. In landscape, the keyboard and the field fill the screen.

Plus the common attributes, such as id and class.

Bind the value

  • Bind value as [value]. iOS and Android have no value attribute.
  • AngularLynx sets the text for you, with setValue, or as default-value before the field is on screen.
  • [attr.value] skips that and doesn't work.

Events

Read the payload from $event.detail. Angular types $event for each event: see Element events.

EventdetailDescription
bindinput{ value: string; selectionStart: number; selectionEnd: number; isComposing?: boolean }The text changed. isComposing is true while a keyboard that builds characters from several keystrokes, such as a Chinese or Japanese one, is mid-character.
bindfocus{ value: string }The field got focus.
bindblur{ value: string }The field lost focus.
bindconfirm{ value: string }The user pressed the keyboard's return key.
bindselection{ selectionStart: number; selectionEnd: number }The cursor or the selection moved.
bindbeforeinput{ value: string; cursor: number; length: number; replace: string; isComposing?: boolean }iOS only. An edit is about to replace length characters from cursor with replace. value is the text before it.
bindkeyboardheightchange{ height: number }iOS and Android. The keyboard showed, changed size or hid (0) while the field has focus. iOS: points from the window's bottom. Android: physical pixels from the Lynx view's bottom.
bindkeyboard{ show: boolean; keyboardHeight?: number; safeAreaBottom?: number }iOS only. The keyboard is showing or hiding. As it shows, it also sends its height and the bottom safe-area inset, in points.

Plus the common events, such as bindtap.

Restyling on focus

On iOS, a focused field doesn't show style changes: a border or background color that bindfocus sets appears on Android and in the web preview, but not on iOS while the field has focus.

Methods

These UI methods (Glossary) control the field from code. Call them with invoke() on the element (see Call element methods). A call from a handler returns nothing: to read a result, call invoke() in a main-thread script instead.

MethodParametersDescription
focus—Focuses the field and opens the keyboard.
blur—Removes focus and closes the keyboard.
getValue—Returns { value, selectionStart, selectionEnd, isComposing }.
setValue{ value: string }Replaces the text. A [value] binding calls this for you.
setSelectionRange{ selectionStart: number; selectionEnd: number }Selects a range of characters. Equal values place the cursor.
import { Component, ElementRef, viewChild } from '@angular/core';
import { LYNX_ELEMENTS } from '@blotch/angular-lynx';

@Component({
  selector: 'app-search-box',
  imports: [LYNX_ELEMENTS],
  template: `
    <input #search placeholder="Search" />
    <view (bindtap)="startSearch()"><text>Search</text></view>
  `,
})
export class SearchBox {
  readonly search = viewChild.required('search', { read: ElementRef });

  startSearch(): void {
    this.search().nativeElement.invoke?.('focus');
  }
}
  • Forms: reactive forms, validation and the on-screen keyboard
  • <textarea>
  • Input: the styled UI component
  • Elements: the form value accessors for formControl and ngModel