This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.
TextField
A SwiftUI TextField component for text input.
Expo UI TextField matches the official SwiftUI TextField API and supports single-line and multiline input, keyboard configuration, submit handling, and an imperative ref for programmatic control.
Installation
If you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Basic text field
Multiline text field
Set axis="vertical" to allow the text field to expand vertically. Use the lineLimit modifier to control the visible line count. When using Host matchContents, add fixedSize({ horizontal: false, vertical: true }) so the text field accepts the parent's width while using its ideal height.
Keyboard type
Use the keyboardType modifier to display a specific keyboard layout.
Submit handling
Use the submitLabel modifier to customize the return key and onSubmit to handle the submit action.
Imperative ref
Use a ref to imperatively set text, focus, blur, or select text.
API
import { TextField } from '@expo/ui/swift-ui';
Component
Type: React.Element<TextFieldProps>
Renders a SwiftUI TextField.
boolean • Default: falseIf true, the text field will be focused automatically when mounted.
string • Default: 'horizontal'The axis along which the text field grows when content exceeds a single line.
'horizontal'— single line (default).'vertical'— expands vertically for multiline content. UselineLimitmodifier to cap visible lines.
Acceptable values are: 'horizontal' | 'vertical'
stringInitial value displayed when mounted. Uncontrolled — change key to reset.
(focused: boolean) => voidA callback triggered when the field gains or loses focus.
({ start, end }: {
end: number,
start: number
}) => voidA callback triggered when user selects text in the TextField.
(value: string) => voidA callback triggered when the text value changes.
Ref<TextFieldRef>