Expo UI SecureField matches the official SwiftUI SecureField API and provides a text field that masks user input for passwords and other sensitive text.
import{ useState }from'react';import{Host,SecureField}from'@expo/ui/swift-ui';exportdefaultfunctionBasicSecureFieldExample(){const[password, setPassword]=useState('');// A secure field stretches to the width it is given, so give the host a size.return(<Hoststyle={{ flex:1}}><SecureFieldplaceholder="Password"onTextChange={setPassword}/></Host>);}
Submit handling
Use the submitLabel and onSubmit modifiers to handle form submission from the keyboard.
Slot children - supports <SecureField.Placeholder> with a <Text> child
maxLength
iOS
tvOS
Optional • Type: number
Maximum number of UTF-16 code units allowed, as JavaScript counts string length. Truncates natively as the user types.
onFocusChange
iOS
tvOS
Optional • Type: (focused: boolean) => void
A callback triggered when the field gains or loses focus.
onTextChange
iOS
tvOS
Optional • Type: (text: string) => void
A callback triggered when the text value changes.
If the callback is marked with the 'worklet' directive, it runs synchronously
on the UI thread; otherwise it is delivered asynchronously as a regular JS event.
An observable state that holds the current text.
Create one with useNativeState('') or useNativeState('initial value').
If omitted, the field manages its own internal state.