Password Field
React Native (Expo)
A React Native password input with a Show and Hide button and a border that eases to the accent colour on focus.
A password input with a Show and Hide button at its end. The border eases to the accent colour while the field has focus. The button says what it will do, so a screen reader hears "Show password" and then "Hide password". Built for React Native and Expo with react-native only; this page previews it in the browser through react-native-web.
Installation
CLI
npx @modus-ui/cli add password-fieldManual
- Copy the code from the component tab.
- Create a file at
components/ui/password-field.tsx. - Paste the code.
It needs no packages beyond react-native, which your Expo or React Native app already has.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | - | The password text. |
onChangeText | (text: string) => void | - | Called as the text changes. |
placeholder | string | "Password" | Hint shown while the field is empty. |
label | string | "Password" | Spoken name of the field. |
colors | Partial<PasswordFieldColors> | - | Overrides surface, border, focus, text, placeholder and toggle. |
style | StyleProp<ViewStyle> | - | Style for the field's frame. |
Comments