PasswordInput
A password field with a show/hide toggle and an optional strength meter.
Status: beta. Category: Forms.
import { PasswordInput } from '@glyphui/ui'
Exports: PasswordInput, passwordStrength, passwordInputStyles.
Notes
- The toggle is a real button with aria-pressed, so screen readers announce whether the password is visible.
- The strength meter is a hint for people. Enforce password rules on the server.
PasswordInput props
| Prop | Type | Default | Description |
|---|---|---|---|
defaultVisible | boolean | Start with the password visible. | |
inputClassName | string | Classes for the <input> element itself. className styles the outer frame. | |
prefix | ReactNode | Content before the text, e.g. an icon or https://. | |
showStrength | boolean | Show a strength meter under the field once the user starts typing. | |
size | "sm" | "md" | "lg" |
Example: Sign in
import { Field, PasswordInput } from '@glyphui/ui'
export default function Example() {
return (
<Field label="Password" className="w-72">
<PasswordInput placeholder="Your password" />
</Field>
)
}
Example: New password with strength
passwordStrength() is exported too.
import { Field, PasswordInput } from '@glyphui/ui'
export default function Example() {
return (
<Field
label="New password"
description="At least 12 characters, mixing letters, numbers and symbols."
className="w-80"
>
<PasswordInput autoComplete="new-password" showStrength />
</Field>
)
}