TextField
用于文本输入的 SwiftUI TextField 组件。
For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.
一个允许用户输入和编辑文本的文本字段组件。
安装
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
import { Host, TextField } from '@expo/ui/swift-ui'; <Host matchContents> <TextField autocorrection={false} defaultValue="单行文本输入" onChangeText={setValue} /> </Host>
更多信息请参阅 官方 SwiftUI 文档。
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>Types
Can be used for imperatively setting text and focus on the TextField component.