PasswordInput
Masked text input with a lock icon and a reveal toggle.
Props
PasswordInput wraps Input with a reveal toggle that controls the input type. Standard input attributes are forwarded. The default leading icon is a lock; pass leftIcon={null} to omit it.
| Prop | Type | Default | Description |
|---|---|---|---|
revealable | boolean | true | Renders the reveal toggle. Off leaves a plain masked field. |
revealed | boolean | — | Controlled reveal state. |
defaultRevealed | boolean | false | Initial reveal state when uncontrolled. |
onRevealedChange | (revealed: boolean) => void | — | Fires when the toggle is pressed. |
showLabel | string | "Show password" | Accessible name for the toggle while masked. |
hideLabel | string | "Hide password" | …and while showing. |
size | "sm" | "md" | "md" | Input height. Icon dimensions follow the control size. |
leftIcon | ReactNode | <IconLock /> | Leading icon content. Pass null to hide the icon. |
rightIcon | ReactNode | — | Trailing Input content. Used only when revealable is false; otherwise the reveal button occupies this slot. |
invalid | boolean | — | From Input. Red border and focus ring; defaults to the enclosing Field's error state. |
mono | boolean | — | From Input. Renders the value in the mono family. |
containerClassName | string | — | From Input. Targets the shell; className targets the <input>. |
Examples
Sign in
Choosing one
Pair it with PasswordStrength while a password is being set. Pass revealable={false} to the confirmation field.
import { PasswordInput, PasswordStrength } from "@solarius/onset";
<Field label="New password" hint="At least 12 characters.">
<Stack gap="2">
<PasswordInput
value={password}
onChange={(e) => setPassword(e.currentTarget.value)}
/>
<PasswordStrength value={password} minLength={12} />
</Stack>
</Field>;PasswordStrength
Renders one UsageBar in the tone matching the score's level (red, amber, green), plus a word for that level so color is not the only carrier. It is role="status": the word is announced when the level changes, and nothing is announced for the keystrokes in between.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | — | The password being typed. |
minLength | number | 8 | What counts as long enough. Match the rule the server enforces. |
strength | PasswordStrengthResult | — | Password strength result supplied by an external estimator or server. |
labels | Partial<Record<PasswordStrengthLevel, ReactNode>> | — | Replace any of the four readouts. |
showLabel | boolean | true | Show the word beside the bar. |
hideWhenEmpty | boolean | true | Render nothing until something has been typed. |
estimatePasswordStrength scores length and character variety. The estimate does not enforce password policy. Pass a strength result to use another estimator. Validate password requirements on the server.
import { PasswordStrength, type PasswordStrengthResult } from "@solarius/onset";
const { score } = zxcvbn(password); // 0–4
const strength: PasswordStrengthResult = {
level: score < 2 ? "weak" : score < 3 ? "fair" : "strong",
score: score * 25,
};
<PasswordStrength value={password} strength={strength} />;