A password field with an eye toggle to show or hide what you type, and a strength meter that shows the password level as you type.
Click the eye to show your password; click again to hide it. Once you start typing, a strength bar slides in below and fills as the password gets stronger.
Options you can pass to customize this component.
valuestringThe current password. Pass it to control the input yourself; leave it out to let the component track its own state.
defaultValuestringStarting password when the input is uncontrolled.
onChange(value: string) => voidFires on every edit with the full password.
defaultVisiblebooleanStarts with the password shown.
onVisibleChange(visible: boolean) => voidFires when the eye shows or hides the password.
strengthbooleanShows the four step strength bar under the field once there is something typed, labeled Weak, Fair, Good or Strong.
placeholderstringText shown while the field is empty.
disabledbooleanBlocks input and dims the whole field.
classNamestringExtra classes for the wrapper around the field and the bar.
inputClassNamestringExtra classes for the native input. Any other input prop, like name or autoComplete, goes to it as well.
npx shadcn@latest add swamimalode07/rare-ui/password-inputimport { useState } from "react"import PasswordInput from "@/components/ui/password-input"export function Demo() {const [password, setPassword] = useState("")return (<PasswordInputname="password"autoComplete="new-password"placeholder="Enter a password"value={password}onChange={setPassword}/>)}
Click the code icon in the top-right corner to view the source code.
Most components here are recreations of great work from around the web. I don't claim to be the original creator - this is my attempt to reverse-engineer, replicate, and often add a few extra features. I've tried to credit everyone; if I missed someone, let me know.
1