πŸš€ 8.9 Released! β†’ ⚑️ New Node-API Engine Preview, πŸ“² ns widget ios, πŸ’… Tailwind v4 and more...
Read Announcement

<TextField> is a UI component for single-line text entry.

For multi-line text input, see TextView.

xml
<TextFieldhint="Placeholder..." />
html
<TextFieldhint="Placeholder..." />
tsx
<textFieldhint="Type here" />
tsx
<textfieldhint="Placeholder..." />
svelte
<textFieldhint="Placeholder..." />
vue
<TextFieldhint="Placeholder..." />

Examples ​

Formatting text inside a TextField ​

If you need to style parts of the text, you can use a combination of a FormattedString and Span elements.

xml
<TextField>
 <FormattedString>
 <Spantext="This text has a " />
 <Spantext="red "style="color: red" />
 <Spantext="piece of text. " />
 <Spantext="Also, this bit is italic, "fontStyle="italic" />
 <Spantext="and this bit is bold."fontWeight="bold" />
 </FormattedString>
</TextField>

Props ​

text ​

ts
text: string

Gets or sets the text of the TextField.

hint ​

ts
hint: string

Gets or sets the placeholder text for the TextField.

editable ​

ts
editable: boolean

When set to false the TextField is read-only.

Defaults to true.

keyboardType ​

ts
keyboardType: CoreTypes.KeyboardType | number // "datetime" | "email" | "integer" | "number" | "phone" | "url"

Gets or sets the keyboard type shown when editing this TextField.

On iOS, any valid UIKeyboardType number works, for example:

ts
keyboardType =8// UIKeyboardType.DecimalPad

See CoreTypes.KeyboardType, UIKeyboardType.

returnKeyType ​

ts
returnKeyType: CoreTypes.ReturnKeyType // "done" | "go" | "next" | "search" | "send"

Gets or sets the label of the return key.

See CoreTypes.ReturnKeyType.

isEnabled ​

Allows disabling the TextField. A disabled TextField does not react to user gestures or input.

Default value is true.

maxLength ​

ts
maxLength: number

Limits input to the specified number of characters.

secure ​

ts
secure: boolean

Hides the entered text when true. Useful for password input fields.

Defaults to false.

secureWithoutAutofill ​

ts
secureWithoutAutofill: boolean

Prevents iOS 12+ auto suggested strong password handling. iOS only

Defaults to false.

autocapitalizationType ​

ts
autocapitalizationType: CoreTypes.AutocapitalizationType // "allCharacters" | "none" | "sentences" | "words"

Gets or sets the autocapitalization type.

See CoreTypes.AutocapitalizationType

...Inherited ​

For additional inherited properties, refer to the API Reference.

Methods ​

focus() ​

ts
focus(): boolean

Focuses the TextField and returns true if the focus was succeessful.

dismissSoftInput() ​

ts
dismissSoftInput(): void

Hides the on-screen keyboard.

Events ​

textChange ​

ts
on('textChange', (args:PropertyChangeData) => {
consttextField= args.object asTextField
 console.log('TextField text changed:', args.value)
})

Emitted when the input text changes.

Event data type: PropertyChangeData

returnPress ​

ts
on('returnPress', (args:EventData) => {
consttextField= args.object asTextField
 console.log('TextField return key pressed.')
})

Emitted when the return key is pressed.

focus ​

ts
on('focus', (args:EventData) => {
consttextField= args.object asTextField
 console.log('TextField has been focused')
})

Emitted when the TextField gains focus.

blur ​

ts
on('blur', (args:EventData) => {
consttextField= args.object asTextField
 console.log('TextField has been blured')
})

Emitted when the TextField loses focus.

Native component ​

Previous
TabView

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /