Password Strength, animated React component
A password field with a four-segment meter that fills and recolours as you type, a rolling strength label, rules that tick themselves off, and an eye toggle that draws its own slash.
- Free
- Signup Forms
- Spring
Play with it
Move the controls and watch it change. Copy code gives you a snippet with only the props you changed.
StrengthEnter a password
- 8+ characters(not met)
- Upper & lower case(not met)
- A number(not met)
- A symbol(not met)
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| onChange | (value: string, score: number) => void | — | Called on every keystroke with the password and its score from 0 to 4. |
| accent | string | "#0071e3" | Colour of the ticked rules and the focus ring. |
| autoplay | boolean | false | Types a sample password until someone clicks in. |
Add it to your project
- 1
Prepare your project
You need Tailwind CSS and the
@/import alias. If shadcn isn't set up yet, initialise it once:npx shadcn@latest init
Then add the Nexus registry to your
components.json(theregistrieskey is the part that matters):{ "$schema": "https://ui.shadcn.com/schema.json", "style": "default", "rsc": true, "tsx": true, "tailwind": { "css": "src/app/globals.css", "baseColor": "neutral", "cssVariables": true, "prefix": "" }, "aliases": { "components": "@/components", "utils": "@/lib/utils", "ui": "@/components/ui", "lib": "@/lib", "hooks": "@/hooks" }, "registries": { "@nexus-labs": "https://www.nexus-ui.com/api/registry/{name}" } } - 2
Add the component
Run this from your project root. It adds the component, the utilities it uses and its packages.
npx shadcn@latest add @nexus-labs/password-strength
- 3
Check what was added
With the standard aliases, these files land in your project:
components/password-strength/index.tspassword-strength.tsx - 4
Copying by hand? Install the packages
Skip this if you used the command above.
npm install framer-motion
- 5
Use it in a page
Import it and render it. The Code tab above has the full example.
// app/page.tsx import { PasswordStrength } from "@/components/password-strength"; export default function Page() { return ( <main> <PasswordStrength /> </main> ); }