Modus UI

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-field

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/password-field.tsx.
  3. Paste the code.

It needs no packages beyond react-native, which your Expo or React Native app already has.

Usage

tsx
import { useState } from "react";
import { PasswordField } from "@/components/ui/password-field";

export default function Example() {
  const [password, setPassword] = useState("");

  return <PasswordField value={password} onChangeText={setPassword} />;
}

Props

PropTypeDefaultDescription
valuestring-The password text.
onChangeText(text: string) => void-Called as the text changes.
placeholderstring"Password"Hint shown while the field is empty.
labelstring"Password"Spoken name of the field.
colorsPartial<PasswordFieldColors>-Overrides surface, border, focus, text, placeholder and toggle.
styleStyleProp<ViewStyle>-Style for the field's frame.

Comments

  • No comments yet.