Password
Password field with a four-segment pixel strength meter, a show/hide toggle and a rule checklist; minScore blocks weak passwords.
Playground
Change a prop and the component re-renders. Props marked remounts set an initial value, so the component starts over.
<PxPassword label="New password" minScore={3} />Installation
pnpm dlx shadcn@latest add @lumesec/px-passwordFirst timeRegister the @lumesec registry once, or install by URL+
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/px-password.jsonUsage
import { PxPassword } from "@/components/lumesec/px-password";
export function Example() {
return <PxPassword name="password" label="New password" minScore={3} />;
}Behaviour
A pixel strength meter in four segments, a show/hide toggle and a checklist whose bullets pop as each rule is met. With minScore set, weaker passwords block form submission.
API reference
Props
Also accepts every prop of <div> (React.ComponentProps<"div">), spread onto the root element.
valueTypestringControlled password. Use with onValueChange.
defaultValueTypestringDefault""Initial password when uncontrolled.
labelTypeReact.ReactNodeDefault"Password"Label above the field, linked to the input.
nameTypestringForm field name; the password submits under it.
minScoreTypePxPasswordScoreDefault0Lowest acceptable strength from 0 to 4 (Too weak, Weak, Fair, Good, Strong). A weaker password makes the input invalid.
disabledTypebooleanDefaultfalseDims the field and disables the input and the show/hide button.
onValueChangeType(value: string) => voidCalled on every edit with the new password.
onScoreChangeType(score: PxPasswordScore) => voidCalled on every edit with the strength score of the new password, 0 to 4.
onValueCommitType(value: string, score: PxPasswordScore) => voidCalled when the input commits a change (on blur after editing), with the password and its score.
Ref
ref points at the root HTMLDivElement.
Accessibility
- A native
<input type="password">withautocomplete="new-password", labelled by a<label htmlFor>. - The show/hide button has
aria-pressedand anaria-labelthat switches between "Show password" and "Hide password". - The meter canvas has
role="meter",aria-label="Password strength",aria-valuemin="0",aria-valuemax="4",aria-valuenowand anaria-valuetextwith the strength word. - The strength word is an
aria-live="polite"region. - The rule checklist is a plain list; met rules change colour only, without a text or ARIA state.
- A native
<input>submits the password undername. When the score is belowminScoreit sets a custom validity message naming the required level, for example "Choose a stronger password (Good or better)", which blocks submission. Form reset clears the password and callsonValueChange. - Reduced motion: the meter jumps to the new score, checklist bullets do not pop and the strength word swaps without rolling.
Theming
Styled with Tailwind classes on your shadcn theme tokens, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --foreground, --muted-foreground, --card, --border, --lumesec, --lumesec-shine, --destructive, --lumesec-warning and --lumesec-success.
Notes
- Scoring: one point each for 8 or more characters, upper and lower case, a number and a symbol. 12 or more characters with at least three of those score 4.
- Strength words and rules are in English.
classNameand otherdivprops go to the wrapper.
Related
Was this page helpful?