Password field
Secure entry with an accessible reveal action and platform-specific password-manager hints.
npx @swipeui/cli add password-fieldWhen to use it
- Sign-in screens where people enter their existing password.
- Sign-up and change-password screens where password managers should suggest a strong password.
- Any secret entry where people may want to check what they typed.
When not to use it
- One-time codes. Use OTP input.
- PINs on a custom keypad.
- Non-secret text.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add password-field- Adds
components/swipeui/ui/password-field.tsxand 14 shared helpers. - Installs react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-svg. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { PasswordField } from '@/components/swipeui/ui/password-field';
<PasswordField label="Password" purpose="new" />;Examples
Use the variant and appearance controls in the live specimen to compare the documented states. The application owns validation, operation results and persistence.
API reference
PasswordFieldProps
| Prop | Type | Default | Description |
|---|---|---|---|
label? | | — | Visible label, or inherit an enclosing Field. |
helper? | | — | Instructions under the field; an error or success message replaces it. |
error? | | — | Validation message: a destructive ring, an alert glyph, one shake and an error haptic. |
success? | | — | Confirmation under the field, such as "Username available", in the success colour. |
status? | | |
|
required? | | | Required; "Required" is spoken, and |
requiredIndicator? | | | How a required label is marked: a muted asterisk, the word, or nothing. |
optionalIndicator? | | | Show a muted "Optional" after the label. |
disabled? | | | Disable editing and accessory actions. |
disabledStyle? | | |
|
appearance? | | | The surface: |
size? | | | Height: |
shape? | | |
|
labelPlacement? | | |
|
focusRing? | | | The focus indicator: a primary ring with a soft halo, the ring alone, or none. |
messageMorph? | | | How a changed message arrives: rises in, letter by letter, or at once. |
reserveMessageSpace? | | | Keep one line of room under the field so forms don't move as messages appear. |
value? | | — | Controlled text. |
defaultValue? | | | Initial uncontrolled text. |
onValueChange? | | — | Reports changed text, including clearing and undo. |
onChangeText? | | — | Native-compatible text callback, in addition to onValueChange. |
displayValue? | | — | Decorative rendering for an unfocused value; the native text remains the accessible/editable source. |
prefix? | | — | Decorative prefix or an accessible accessory, drawn first. |
leadingIcon? | | — | A leading icon: a node, or a function given the state colour and size. It turns primary while focused. |
trailingIcon? | | — | A trailing icon: a node, or a function given the state colour and size. |
clearable? | | | 1.x switch: |
clearButton? | | | When a "Clear text" button shows. |
undoClear? | | | After clearing, the button becomes "Undo clear" for a moment. Phones have no ⌘Z. |
undoClearWindow? | | | How long undo stays, in milliseconds. |
counter? | | | A rolling character counter under the field, using |
tintCaret? | | | Caret and selection in the primary colour. |
iconTint? | | | The leading icon turns primary while focused ( |
shakeOnError? | | | Shake once for each new error. Reduce Motion keeps it still. |
messages? | | | Built-in strings, for translation. |
nextRef? | | — | Ref focused when Return is pressed; otherwise a single-line field dismisses. |
haptics? | | | All feedback, or each part: |
motion? | | | Ring, label and message motion. |
className? | | — | Classes on the outer field. |
controlClassName? | | — | Classes on the field surface. |
inputClassName? | | — | Classes on the editable text. |
style? | | — | Outer field style. |
inputStyle? | | — | Native editable text style. |
purpose? | | | Password-manager intent. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Composition and behavior
- A filled Text field with secure entry and an eye morph in the suffix.
- purpose sets the platform autofill hints.
- Pair with Password strength on sign-up.
Password field settings
The reveal action is an eye icon that morphs between open and closed states inside the shared filled field. It keeps keyboard focus.
| Prop | Does | Default |
|---|---|---|
| purpose | Password-manager intent | current |
| appearance | Shared field surface | filled |
| motion | Eye morph and field motion | app feel |
Behavior and gestures
- Text is hidden as you type; tap the eye icon to reveal or hide it without losing input focus.
- purpose="new" asks iOS and Android password managers to suggest a strong password; current asks them to fill a saved one.
- The reveal button is disabled when the field is disabled or read-only.
Accessibility
- The reveal button is named "Show password" or "Hide password" and reports its state.
- Labelled like Text field, with helper and error.
- Screen readers don't read hidden characters aloud.
Motion
- Uses the
pressmotion role, so it follows your app's feel. Passmotionto tune this one instance. - The reveal button uses the shared press scale.
Performance
- Same cost as Text field.
Notes for AI
- Use purpose="new" for sign-up and change-password, "current" for sign-in.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.