TextView
<textView> is a UI component that shows an editable or a read-only multi-line text container. You can use it to let users type large text in your app or to show longer, multi-line text on the screen.
<textView> extends TextBase and EditableTextBase which provide additional properties and events.
See also:
<textView text={"Multi\nLine\nText"} />
Displaying multi-style text
To apply multiple styles to the text in your <textView>, you can use <formattedString>:
import * as React from "react";
<textView editable={false}>
<formattedString>
<span text="You can use text attributes such as " />
<span text="bold, " fontWeight="bold" />
<span text="italic " fontStyle="italic" />
<span text="and " />
<span text="underline." textDecoration="underline" />
<!-- To set text on the <span> element, please do use the `text` prop; it can't safely take text nodes as children! -->
</formattedString>
</textView>
Props
| Name | Type | Description |
|---|---|---|
text | string | Sets the value of the component. |
hint | string | Sets the placeholder text when the component is editable. |
editable | boolean | When true, indicates that the user can edit the contents of the container. |
maxLength | number | Sets the maximum number of characters that can be entered in the container. |
keyboardType | KeyboardType | Shows a custom keyboard for easier text input. Valid values: datetime, phone, number, url, or email. |
returnKeyType | ReturnKeyType | Sets the label of the return key. Valid values: done, next, go, search, or send. |
autocorrect | boolean | Enables or disables autocorrect. |
onBlur | (args:EventData) => void | Emitted when the text view loses focus. |
onFocus | (args:EventData) => void | Emitted when the text view gains focus. |
onTextChange | (args:EventData) => void | Emitted when the text changes. |
Native component
| Android | iOS |
|---|---|
android.widget.EditText | UITextView |