title | description | contributors | ||
---|---|---|---|---|
TextView |
UI component for multi-line text entry. |
|
<TextView>
is a UI component for multi-line text entry. When set to read-only, it can also be used to display multi-line text.
For single-line text input, see TextField.
::: code-group <<< @/../examples/typescript/src/ui/TextView/template.xml#example [XML] <<< @/../examples/typescript/src/ui/TextView/template.ts#example [TypeScript] :::
::: code-group <<< @/../examples/angular/src/ui/TextView/component.html#example [HTML] <<< @/../examples/angular/src/ui/TextView/component.ts#example [TypeScript] :::
<<< @/../examples/react/src/components/ui/textview.tsx#example
<<< @/../examples/solid/src/ui/textview.tsx#example
<<< @/../examples/svelte/app/components/ui/TextView.svelte#example
<<< @/../examples/vue/src/ui/TextView/component.vue#example
If you need to style parts of the text, you can use a combination of a FormattedString
and Span
elements.
<TextView>
<FormattedString>
<Span text="This text has a " />
<Span text="red " style="color: red" />
<Span text="piece of text. " />
<Span text="Also, this bit is italic, " fontStyle="italic" />
<Span text="and this bit is bold." fontWeight="bold" />
</FormattedString>
</TextView>
text: string
Gets or sets the text of the TextView.
hint: string
Gets or sets the placeholder text for the TextView.
editable: boolean
When set to false
the TextView is read-only.
Defaults to true
.
keyboardType: CoreTypes.KeyboardType | number // "datetime" | "email" | "integer" | "number" | "phone" | "url"
Gets or sets the keyboard type shown when editing this TextView.
On iOS, any valid UIKeyboardType
number works, for example:
keyboardType = 8 // UIKeyboardType.DecimalPad
See CoreTypes.KeyboardType, UIKeyboardType.
returnKeyType: CoreTypes.ReturnKeyType // "done" | "go" | "next" | "search" | "send"
Gets or sets the label of the return key.
Allows disabling the TextView. A disabled TextView does not react to user gestures or input.
Default value is true
.
maxLines: number
Limits input to the specified number of lines.
autocorrect: boolean
Enables or disables autocorrect.
(iOS Only) Are Apple Intelligence writing tools active.
isWritingToolsActive: boolean
(iOS Only) Allow Apple Intelligence writing tools to emit text changes on each alteration instead of after the final change (default).
enableWritingToolsEvents: boolean
(iOS Only) Behavior for Apple Intelligence Writing Tools.
iosWritingToolsBehavior: WritingToolsBehavior
Can be Default
, Complete
, Limited
or None
.
(iOS Only) Allowed input for Apple Intelligence Writing Tools.
iosWritingToolsAllowedInput: Array<WritingToolsAllowedInput>
Can be Default
, List
, PlainText
, RichText
or Table
.
For additional inherited properties not shown, refer to the API Reference.
focus(): boolean
Focuses the TextView and returns true
if the focus was succeessful.
dismissSoftInput(): void
Hides the on-screen keyboard.
on('textChange', (args: PropertyChangeData) => {
const textView = args.object as TextView
console.log('TextView text changed:', args.value)
})
Emitted when the input text changes.
Event data type: PropertyChangeData
on('returnPress', (args: EventData) => {
const textView = args.object as TextView
console.log('TextView return key pressed.')
})
Emitted when the return key is pressed.
on('focus', (args: EventData) => {
const textView = args.object as TextView
console.log('TextView has been focused')
})
Emitted when the TextView gains focus.
on('blur', (args: EventData) => {
const textView = args.object as TextView
console.log('TextView has been blured')
})
Emitted when the TextView loses focus.
- Android:
android.widget.EditText
- iOS:
UITextView