Password input

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.

Dependencies

motion

Interaction 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.

Props

Options you can pass to customize this component.

Prop
Type
Description
value
string

The current password. Pass it to control the input yourself; leave it out to let the component track its own state.

defaultValue
string

Starting password when the input is uncontrolled.

onChange
(value: string) => void

Fires on every edit with the full password.

defaultVisible
boolean

Starts with the password shown.

onVisibleChange
(visible: boolean) => void

Fires when the eye shows or hides the password.

strength
boolean

Shows the four step strength bar under the field once there is something typed, labeled Weak, Fair, Good or Strong.

placeholder
string

Text shown while the field is empty.

disabled
boolean

Blocks input and dims the whole field.

className
string

Extra classes for the wrapper around the field and the bar.

inputClassName
string

Extra classes for the native input. Any other input prop, like name or autoComplete, goes to it as well.

Installation

npx shadcn@latest add swamimalode07/rare-ui/password-input

How to use

import { useState } from "react"
import PasswordInput from "@/components/ui/password-input"
export function Demo() {
const [password, setPassword] = useState("")
return (
<PasswordInput
name="password"
autoComplete="new-password"
placeholder="Enter a password"
value={password}
onChange={setPassword}
/>
)
}

Source Code

Click the code icon in the top-right corner to view the source code.

Keep in mind

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.

Contact

Found a bug or issue? Feel free to drop a DM.

License & Usage

  • •MIT with the Commons Clause and an attribution requirement. Free to use, modify and ship in personal and commercial projects, closed source included. You own the code once it is in your project.
  • •Credit is required. Any project shipping a Rare UI component must credit Rare UI with a visible link back to rareui.com, in a footer, an about page, a credits screen or a README.
  • •Don't strip the credit or the copyright notice from the source you copied.
  • •Don't sell, sublicense or redistribute the components themselves, on their own, bundled into a template, kit, theme or paid course, or ported to another framework.
  • •Don't republish them. No mirrors, no re-uploads, no listing them as your own work.
  • •Don't repackage the registry as a competing component library.
  • •Don't claim authorship of a component or of Rare UI itself.
  • •The LICENSE file in the repository is the full text and governs. Ask first if your use doesn't fit these rules.
Password input