Password strength
A local meter of length and character hints with an optional application estimator.
npx @swipeui/cli add password-strengthWhen to use it
- Sign-up and change-password screens, to guide people toward a stronger password.
- Showing which simple rules are still missing, such as a number or a symbol.
- Plugging in your own estimator, such as zxcvbn, while keeping the same meter.
When not to use it
- Sign-in screens; don't judge an existing password.
- Enforcing security policy. Validate on the server.
- Claiming a password is secure; the built-in hints only check simple rules.
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-strength- Adds
components/swipeui/ui/password-strength.tsxand 4 shared helpers. - Installs react-native-reanimated, uniwind, react-native-worklets, clsx, tailwind-merge, class-variance-authority. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { PasswordStrength } from '@/components/swipeui/ui/password-strength';
<PasswordStrength value={password} />;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
PasswordStrengthProps
| Prop | Type | Default | Description |
|---|---|---|---|
value | | — | Password evaluated in memory; never sent or logged. |
minLength? | | | Minimum-length hint. |
evaluate? | | — | Optional application estimator, called locally. |
segments? | | | Number of hint segments. |
completionEffect? | | | One rainbow pulse across all the bars when every hint is met: the bars lift in turn and pass red, amber, green and blue along the row before settling green. Reduce Motion keeps them still. |
showHints? | | | Keep the hint checklist visible. |
hintAnimation? | | | Pop each hint when met. |
hintCompletionEffect? | | | Diagonal rainbow text sweep over the hints when every hint is met. Off by default, so the pulse stays on the bars. |
motion? | | | Shared selection motion. |
className? | | — | Root classes. |
style? | | — | Native style escape hatch. |
testID? | | — | Root test identifier. |
Native view/input props not listed here pass through where the exported TypeScript type allows them.
Composition and behavior
- value is the password to check. minLength sets the length hint (12).
- The built-in hints check length, mixed case, a number and a symbol.
- evaluate replaces them with your own score and hints.
Password strength settings
The meter uses one segment per configured hint. One completed segment is red, two are amber, and three or more are green. Meeting every hint plays one rainbow pulse across all the bars: they lift in turn and pass red, amber, green and blue along the row, then settle green. This is guidance, not an entropy estimate.
| Prop | Does | Default |
|---|---|---|
| segments | Number of hint bars; match custom estimators to this count | 4 |
| completionEffect | One rainbow pulse across the bars (still under Reduce Motion) | true |
| minLength | Minimum-length hint | 12 |
Hints remain visible in a centered card; met rules pop and settle. With hintCompletionEffect on, completion also sends a diagonal colour sweep through their text.
| Prop | Does | Default |
|---|---|---|
| showHints | Show the persistent hint card | true |
| hintAnimation | Pop newly met hints | true |
| hintCompletionEffect | Diagonal completion rainbow on hint text | false |
Behavior and gestures
- It updates as people type, filling up to four segments.
- Hints remain visible as a checklist; met rules pop and settle, such as "Use at least 12 characters" or "Add a symbol".
- It doesn't respond to touch.
Accessibility
- Announced as a progress bar called "Password hints" with a value like "2 of 4 hints met".
- Hints are text, not just colour.
- The password is checked in memory and is never sent or logged.
Motion
- Uses the
selectmotion role, so it follows your app's feel. Passmotionto tune this one instance. - Segments fill with the select spring.
- Reduce Motion fills them instantly.
Performance
- The built-in check is four quick tests; heavy estimators should be memoised in your app.
Notes for AI
- Pass evaluate to use your own estimator; scores are clamped to 0–4.
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.