Password input A password field with a show/hide toggle and, for new passwords, a strength word, Meter , and hint. For other text, use an Input .
Installation bun add @harmo-ui/css @harmo-ui/react npm install @harmo-ui/css @harmo-ui/react pnpm add @harmo-ui/css @harmo-ui/react yarn add @harmo-ui/css @harmo-ui/react bunx harmo-ui add password npx harmo-ui add password pnpm dlx harmo-ui add password yarn dlx harmo-ui add password Usage import { PasswordInput } from "@harmo-ui/react" ;
< PasswordInput
label = "New password"
showPasswordLabel = "Show password"
hidePasswordLabel = "Hide password"
autoComplete = "new-password"
strength = { ( password ) =>
password . length < 8
? { level : 1 , word : "Too weak" , status : "error" }
: { level : 3 , word : "Strong" , status : "success" }
}
strengthLabel = "Password strength"
/>
View full source
Examples Current password An Input with a show/hide toggle at its end, which appears once something is typed. The toggle's name stays "Show password", with aria-pressed saying whether the password shows; its Tooltip names the next click.
< PasswordInput
label = "Password"
showPasswordLabel = "Show password"
hidePasswordLabel = "Hide password"
autoComplete = "current-password"
/> < div class = "hfield" >
< label class = "hlabel" for = "current-password" >Password</ label >
< div class = "hpassword" >
< input class = "hinput" id = "current-password" type = "password" autocomplete = "current-password" />
< span class = "htooltip-trigger" >
< button
class = "hpassword-toggle"
type = "button"
aria-label = "Show password"
aria-pressed = "false"
aria-controls = "current-password"
hidden
>
< svg class = "hpassword-icon-show" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M12 16.3299C9.60998 16.3299 7.66998 14.3899 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C14.39 7.66992 16.33 9.60992 16.33 11.9999C16.33 14.3899 14.39 16.3299 12 16.3299ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 13.5599 10.44 14.8299 12 14.8299C13.56 14.8299 14.83 13.5599 14.83 11.9999C14.83 10.4399 13.56 9.16992 12 9.16992Z" />
< path d = "M12 21.02C8.24002 21.02 4.69002 18.82 2.25002 15C1.19002 13.35 1.19002 10.66 2.25002 8.99998C4.70002 5.17998 8.25002 2.97998 12 2.97998C15.75 2.97998 19.3 5.17998 21.74 8.99998C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02ZM12 4.47998C8.77002 4.47998 5.68002 6.41998 3.52002 9.80998C2.77002 10.98 2.77002 13.02 3.52002 14.19C5.68002 17.58 8.77002 19.52 12 19.52C15.23 19.52 18.32 17.58 20.48 14.19C21.23 13.02 21.23 10.98 20.48 9.80998C18.32 6.41998 15.23 4.47998 12 4.47998Z" />
</ svg >
< svg class = "hpassword-icon-hide" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M9.46998 15.2799C9.27998 15.2799 9.08998 15.2099 8.93998 15.0599C8.11998 14.2399 7.66998 13.1499 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C13.15 7.66992 14.24 8.11992 15.06 8.93992C15.2 9.07992 15.28 9.26992 15.28 9.46992C15.28 9.66992 15.2 9.85992 15.06 9.99992L9.99998 15.0599C9.84998 15.2099 9.65998 15.2799 9.46998 15.2799ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 12.4999 9.29998 12.9799 9.53998 13.3999L13.4 9.53992C12.98 9.29992 12.5 9.16992 12 9.16992Z" />
< path d = "M5.60003 18.51C5.43003 18.51 5.25003 18.45 5.11003 18.33C4.04003 17.42 3.08003 16.3 2.26003 15C1.20003 13.35 1.20003 10.66 2.26003 8.99998C4.70003 5.17998 8.25003 2.97998 12 2.97998C14.2 2.97998 16.37 3.73998 18.27 5.16998C18.6 5.41998 18.67 5.88998 18.42 6.21998C18.17 6.54998 17.7 6.61998 17.37 6.36998C15.73 5.12998 13.87 4.47998 12 4.47998C8.77003 4.47998 5.68003 6.41998 3.52003 9.80998C2.77003 10.98 2.77003 13.02 3.52003 14.19C4.27003 15.36 5.13003 16.37 6.08003 17.19C6.39003 17.46 6.43003 17.93 6.16003 18.25C6.02003 18.42 5.81003 18.51 5.60003 18.51Z" />
< path d = "M12 21.02C10.67 21.02 9.37 20.75 8.12 20.22C7.74 20.06 7.56 19.62 7.72 19.24C7.88 18.86 8.32 18.68 8.7 18.84C9.76 19.29 10.87 19.52 11.99 19.52C15.22 19.52 18.31 17.58 20.47 14.19C21.22 13.02 21.22 10.98 20.47 9.81C20.16 9.32 19.82 8.85 19.46 8.41C19.2 8.09 19.25 7.62 19.57 7.35C19.89 7.09 20.36 7.13 20.63 7.46C21.02 7.94 21.4 8.46 21.74 9C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02Z" />
< path d = "M12.69 16.2701C12.34 16.2701 12.02 16.0201 11.95 15.6601C11.87 15.2501 12.14 14.8601 12.55 14.7901C13.65 14.5901 14.57 13.6701 14.77 12.5701C14.85 12.1601 15.24 11.9001 15.65 11.9701C16.06 12.0501 16.33 12.4401 16.25 12.8501C15.93 14.5801 14.55 15.9501 12.83 16.2701C12.78 16.2601 12.74 16.2701 12.69 16.2701Z" />
< path d = "M2 22.75C1.81 22.75 1.62 22.68 1.47 22.53C1.18 22.24 1.18 21.76 1.47 21.47L8.94 14C9.23 13.71 9.71 13.71 10 14C10.29 14.29 10.29 14.77 10 15.06L2.53 22.53C2.38 22.68 2.19 22.75 2 22.75Z" />
< path d = "M14.53 10.2199C14.34 10.2199 14.15 10.1499 14 9.99994C13.71 9.70994 13.71 9.22994 14 8.93994L21.47 1.46994C21.76 1.17994 22.24 1.17994 22.53 1.46994C22.82 1.75994 22.82 2.23994 22.53 2.52994L15.06 9.99994C14.91 10.1499 14.72 10.2199 14.53 10.2199Z" />
</ svg >
</ button >
< span class = "htooltip" role = "tooltip" aria-hidden = "true" >Show password</ span >
</ span >
</ div >
</ div >
View full source
New password Adds a strength word, a Meter, and a hint, which appear as you type. The app supplies the rule and the wording; here, under 10 characters is too weak, and upper case, lower case, digits, and symbols together are strong.
const strength = ( password : string ) : PasswordStrength => {
if ( password . length < 10 ) {
return {
level : 1 ,
word : "Too weak" ,
hint : "Passwords need to be at least 10 characters. Include multiple words and phrases to make it more secure." ,
status : "error" ,
};
}
const kinds = [ / [A-Z] / , / [a-z] / , / \d / , / [!@#$%^&*(),.?":{}|<>] / ];
return kinds . every (( kind ) => kind . test (password))
? { level : 3 , word : "Strong" , status : "success" }
: {
level : 2 ,
word : "Medium" ,
hint : "Include multiple words and phrases to make it more secure." ,
};
};
return (
< PasswordInput
label = "New password"
showPasswordLabel = "Show password"
hidePasswordLabel = "Hide password"
autoComplete = "new-password"
strength = { strength }
strengthLabel = "Password strength"
/>
);
View full source
< div class = "hfield" >
< div class = "hfield-label-row" >
< label class = "hlabel" for = "new-password" >New password</ label >
< span class = "hpassword-strength" id = "new-password-strength" aria-live = "polite" ></ span >
</ div >
< div class = "hpassword" >
< input
class = "hinput"
id = "new-password"
type = "password"
autocomplete = "new-password"
aria-describedby = "new-password-strength new-password-hint"
/>
< span class = "htooltip-trigger" >
< button
class = "hpassword-toggle"
type = "button"
aria-label = "Show password"
aria-pressed = "false"
aria-controls = "new-password"
hidden
>
< svg class = "hpassword-icon-show" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M12 16.3299C9.60998 16.3299 7.66998 14.3899 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C14.39 7.66992 16.33 9.60992 16.33 11.9999C16.33 14.3899 14.39 16.3299 12 16.3299ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 13.5599 10.44 14.8299 12 14.8299C13.56 14.8299 14.83 13.5599 14.83 11.9999C14.83 10.4399 13.56 9.16992 12 9.16992Z" />
< path d = "M12 21.02C8.24002 21.02 4.69002 18.82 2.25002 15C1.19002 13.35 1.19002 10.66 2.25002 8.99998C4.70002 5.17998 8.25002 2.97998 12 2.97998C15.75 2.97998 19.3 5.17998 21.74 8.99998C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02ZM12 4.47998C8.77002 4.47998 5.68002 6.41998 3.52002 9.80998C2.77002 10.98 2.77002 13.02 3.52002 14.19C5.68002 17.58 8.77002 19.52 12 19.52C15.23 19.52 18.32 17.58 20.48 14.19C21.23 13.02 21.23 10.98 20.48 9.80998C18.32 6.41998 15.23 4.47998 12 4.47998Z" />
</ svg >
< svg class = "hpassword-icon-hide" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M9.46998 15.2799C9.27998 15.2799 9.08998 15.2099 8.93998 15.0599C8.11998 14.2399 7.66998 13.1499 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C13.15 7.66992 14.24 8.11992 15.06 8.93992C15.2 9.07992 15.28 9.26992 15.28 9.46992C15.28 9.66992 15.2 9.85992 15.06 9.99992L9.99998 15.0599C9.84998 15.2099 9.65998 15.2799 9.46998 15.2799ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 12.4999 9.29998 12.9799 9.53998 13.3999L13.4 9.53992C12.98 9.29992 12.5 9.16992 12 9.16992Z" />
< path d = "M5.60003 18.51C5.43003 18.51 5.25003 18.45 5.11003 18.33C4.04003 17.42 3.08003 16.3 2.26003 15C1.20003 13.35 1.20003 10.66 2.26003 8.99998C4.70003 5.17998 8.25003 2.97998 12 2.97998C14.2 2.97998 16.37 3.73998 18.27 5.16998C18.6 5.41998 18.67 5.88998 18.42 6.21998C18.17 6.54998 17.7 6.61998 17.37 6.36998C15.73 5.12998 13.87 4.47998 12 4.47998C8.77003 4.47998 5.68003 6.41998 3.52003 9.80998C2.77003 10.98 2.77003 13.02 3.52003 14.19C4.27003 15.36 5.13003 16.37 6.08003 17.19C6.39003 17.46 6.43003 17.93 6.16003 18.25C6.02003 18.42 5.81003 18.51 5.60003 18.51Z" />
< path d = "M12 21.02C10.67 21.02 9.37 20.75 8.12 20.22C7.74 20.06 7.56 19.62 7.72 19.24C7.88 18.86 8.32 18.68 8.7 18.84C9.76 19.29 10.87 19.52 11.99 19.52C15.22 19.52 18.31 17.58 20.47 14.19C21.22 13.02 21.22 10.98 20.47 9.81C20.16 9.32 19.82 8.85 19.46 8.41C19.2 8.09 19.25 7.62 19.57 7.35C19.89 7.09 20.36 7.13 20.63 7.46C21.02 7.94 21.4 8.46 21.74 9C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02Z" />
< path d = "M12.69 16.2701C12.34 16.2701 12.02 16.0201 11.95 15.6601C11.87 15.2501 12.14 14.8601 12.55 14.7901C13.65 14.5901 14.57 13.6701 14.77 12.5701C14.85 12.1601 15.24 11.9001 15.65 11.9701C16.06 12.0501 16.33 12.4401 16.25 12.8501C15.93 14.5801 14.55 15.9501 12.83 16.2701C12.78 16.2601 12.74 16.2701 12.69 16.2701Z" />
< path d = "M2 22.75C1.81 22.75 1.62 22.68 1.47 22.53C1.18 22.24 1.18 21.76 1.47 21.47L8.94 14C9.23 13.71 9.71 13.71 10 14C10.29 14.29 10.29 14.77 10 15.06L2.53 22.53C2.38 22.68 2.19 22.75 2 22.75Z" />
< path d = "M14.53 10.2199C14.34 10.2199 14.15 10.1499 14 9.99994C13.71 9.70994 13.71 9.22994 14 8.93994L21.47 1.46994C21.76 1.17994 22.24 1.17994 22.53 1.46994C22.82 1.75994 22.82 2.23994 22.53 2.52994L15.06 9.99994C14.91 10.1499 14.72 10.2199 14.53 10.2199Z" />
</ svg >
</ button >
< span class = "htooltip" role = "tooltip" aria-hidden = "true" >Show password</ span >
</ span >
</ div >
< div class = "hpassword-details" hidden >
< div >
< div
class = "hmeter"
role = "meter"
aria-label = "Password strength"
aria-valuemin = "0"
aria-valuemax = "3"
aria-valuenow = "0"
>
< span class = "hmeter-segment" ></ span >
< span class = "hmeter-segment" ></ span >
< span class = "hmeter-segment" ></ span >
</ div >
< p class = "hpassword-hint" id = "new-password-hint" ></ p >
</ div >
</ div >
</ div >
View full source
Disabled A disabled field keeps its toggle if it has a value, disabled with it.
API secret, managed by your administrator < PasswordInput
label = "API secret, managed by your administrator"
showPasswordLabel = "Show password"
hidePasswordLabel = "Hide password"
defaultValue = "example-api-secret"
disabled
/> < div class = "hfield" >
< label class = "hlabel" for = "api-secret" >API secret, managed by your administrator</ label >
< div class = "hpassword" >
< input class = "hinput" id = "api-secret" type = "password" value = "example-api-secret" disabled />
< span class = "htooltip-trigger" >
< button
class = "hpassword-toggle"
type = "button"
aria-label = "Show password"
aria-pressed = "false"
aria-controls = "api-secret"
disabled
>
< svg class = "hpassword-icon-show" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M12 16.3299C9.60998 16.3299 7.66998 14.3899 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C14.39 7.66992 16.33 9.60992 16.33 11.9999C16.33 14.3899 14.39 16.3299 12 16.3299ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 13.5599 10.44 14.8299 12 14.8299C13.56 14.8299 14.83 13.5599 14.83 11.9999C14.83 10.4399 13.56 9.16992 12 9.16992Z" />
< path d = "M12 21.02C8.24002 21.02 4.69002 18.82 2.25002 15C1.19002 13.35 1.19002 10.66 2.25002 8.99998C4.70002 5.17998 8.25002 2.97998 12 2.97998C15.75 2.97998 19.3 5.17998 21.74 8.99998C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02ZM12 4.47998C8.77002 4.47998 5.68002 6.41998 3.52002 9.80998C2.77002 10.98 2.77002 13.02 3.52002 14.19C5.68002 17.58 8.77002 19.52 12 19.52C15.23 19.52 18.32 17.58 20.48 14.19C21.23 13.02 21.23 10.98 20.48 9.80998C18.32 6.41998 15.23 4.47998 12 4.47998Z" />
</ svg >
< svg class = "hpassword-icon-hide" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M9.46998 15.2799C9.27998 15.2799 9.08998 15.2099 8.93998 15.0599C8.11998 14.2399 7.66998 13.1499 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C13.15 7.66992 14.24 8.11992 15.06 8.93992C15.2 9.07992 15.28 9.26992 15.28 9.46992C15.28 9.66992 15.2 9.85992 15.06 9.99992L9.99998 15.0599C9.84998 15.2099 9.65998 15.2799 9.46998 15.2799ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 12.4999 9.29998 12.9799 9.53998 13.3999L13.4 9.53992C12.98 9.29992 12.5 9.16992 12 9.16992Z" />
< path d = "M5.60003 18.51C5.43003 18.51 5.25003 18.45 5.11003 18.33C4.04003 17.42 3.08003 16.3 2.26003 15C1.20003 13.35 1.20003 10.66 2.26003 8.99998C4.70003 5.17998 8.25003 2.97998 12 2.97998C14.2 2.97998 16.37 3.73998 18.27 5.16998C18.6 5.41998 18.67 5.88998 18.42 6.21998C18.17 6.54998 17.7 6.61998 17.37 6.36998C15.73 5.12998 13.87 4.47998 12 4.47998C8.77003 4.47998 5.68003 6.41998 3.52003 9.80998C2.77003 10.98 2.77003 13.02 3.52003 14.19C4.27003 15.36 5.13003 16.37 6.08003 17.19C6.39003 17.46 6.43003 17.93 6.16003 18.25C6.02003 18.42 5.81003 18.51 5.60003 18.51Z" />
< path d = "M12 21.02C10.67 21.02 9.37 20.75 8.12 20.22C7.74 20.06 7.56 19.62 7.72 19.24C7.88 18.86 8.32 18.68 8.7 18.84C9.76 19.29 10.87 19.52 11.99 19.52C15.22 19.52 18.31 17.58 20.47 14.19C21.22 13.02 21.22 10.98 20.47 9.81C20.16 9.32 19.82 8.85 19.46 8.41C19.2 8.09 19.25 7.62 19.57 7.35C19.89 7.09 20.36 7.13 20.63 7.46C21.02 7.94 21.4 8.46 21.74 9C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02Z" />
< path d = "M12.69 16.2701C12.34 16.2701 12.02 16.0201 11.95 15.6601C11.87 15.2501 12.14 14.8601 12.55 14.7901C13.65 14.5901 14.57 13.6701 14.77 12.5701C14.85 12.1601 15.24 11.9001 15.65 11.9701C16.06 12.0501 16.33 12.4401 16.25 12.8501C15.93 14.5801 14.55 15.9501 12.83 16.2701C12.78 16.2601 12.74 16.2701 12.69 16.2701Z" />
< path d = "M2 22.75C1.81 22.75 1.62 22.68 1.47 22.53C1.18 22.24 1.18 21.76 1.47 21.47L8.94 14C9.23 13.71 9.71 13.71 10 14C10.29 14.29 10.29 14.77 10 15.06L2.53 22.53C2.38 22.68 2.19 22.75 2 22.75Z" />
< path d = "M14.53 10.2199C14.34 10.2199 14.15 10.1499 14 9.99994C13.71 9.70994 13.71 9.22994 14 8.93994L21.47 1.46994C21.76 1.17994 22.24 1.17994 22.53 1.46994C22.82 1.75994 22.82 2.23994 22.53 2.52994L15.06 9.99994C14.91 10.1499 14.72 10.2199 14.53 10.2199Z" />
</ svg >
</ button >
< span class = "htooltip" role = "tooltip" aria-hidden = "true" >Show password</ span >
</ span >
</ div >
</ div >
View full source
Disabling Disabling the input disables its toggle too. Type a password, then clear the checkbox, which turns the field off, as an app's settings might.
const [ protecting , setProtecting ] = useState ( true );
return (
<>
< Field orientation = "horizontal" label = "Protect the export with a password" >
< Checkbox
name = "export-protect"
checked = { protecting }
onChange = { ( event ) => setProtecting ( event . target .checked) }
/>
</ Field >
< PasswordInput
label = "Export password"
showPasswordLabel = "Show password"
hidePasswordLabel = "Hide password"
autoComplete = "new-password"
disabled = { ! protecting }
/>
</>
);
View full source
< div class = "hfield" data-orientation = "horizontal" >
< input class = "hcheckbox" type = "checkbox" id = "export-protect" name = "export-protect" checked />
< label class = "hlabel" for = "export-protect" >Protect the export with a password</ label >
</ div >
< div class = "hfield" >
< label class = "hlabel" for = "export-password" >Export password</ label >
< div class = "hpassword" >
< input class = "hinput" id = "export-password" type = "password" autocomplete = "new-password" />
< span class = "htooltip-trigger" >
< button
class = "hpassword-toggle"
type = "button"
aria-label = "Show password"
aria-pressed = "false"
aria-controls = "export-password"
hidden
>
< svg class = "hpassword-icon-show" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M12 16.3299C9.60998 16.3299 7.66998 14.3899 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C14.39 7.66992 16.33 9.60992 16.33 11.9999C16.33 14.3899 14.39 16.3299 12 16.3299ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 13.5599 10.44 14.8299 12 14.8299C13.56 14.8299 14.83 13.5599 14.83 11.9999C14.83 10.4399 13.56 9.16992 12 9.16992Z" />
< path d = "M12 21.02C8.24002 21.02 4.69002 18.82 2.25002 15C1.19002 13.35 1.19002 10.66 2.25002 8.99998C4.70002 5.17998 8.25002 2.97998 12 2.97998C15.75 2.97998 19.3 5.17998 21.74 8.99998C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02ZM12 4.47998C8.77002 4.47998 5.68002 6.41998 3.52002 9.80998C2.77002 10.98 2.77002 13.02 3.52002 14.19C5.68002 17.58 8.77002 19.52 12 19.52C15.23 19.52 18.32 17.58 20.48 14.19C21.23 13.02 21.23 10.98 20.48 9.80998C18.32 6.41998 15.23 4.47998 12 4.47998Z" />
</ svg >
< svg class = "hpassword-icon-hide" viewBox = "0 0 24 24" fill = "currentColor" aria-hidden = "true" focusable = "false" >
< path d = "M9.46998 15.2799C9.27998 15.2799 9.08998 15.2099 8.93998 15.0599C8.11998 14.2399 7.66998 13.1499 7.66998 11.9999C7.66998 9.60992 9.60998 7.66992 12 7.66992C13.15 7.66992 14.24 8.11992 15.06 8.93992C15.2 9.07992 15.28 9.26992 15.28 9.46992C15.28 9.66992 15.2 9.85992 15.06 9.99992L9.99998 15.0599C9.84998 15.2099 9.65998 15.2799 9.46998 15.2799ZM12 9.16992C10.44 9.16992 9.16998 10.4399 9.16998 11.9999C9.16998 12.4999 9.29998 12.9799 9.53998 13.3999L13.4 9.53992C12.98 9.29992 12.5 9.16992 12 9.16992Z" />
< path d = "M5.60003 18.51C5.43003 18.51 5.25003 18.45 5.11003 18.33C4.04003 17.42 3.08003 16.3 2.26003 15C1.20003 13.35 1.20003 10.66 2.26003 8.99998C4.70003 5.17998 8.25003 2.97998 12 2.97998C14.2 2.97998 16.37 3.73998 18.27 5.16998C18.6 5.41998 18.67 5.88998 18.42 6.21998C18.17 6.54998 17.7 6.61998 17.37 6.36998C15.73 5.12998 13.87 4.47998 12 4.47998C8.77003 4.47998 5.68003 6.41998 3.52003 9.80998C2.77003 10.98 2.77003 13.02 3.52003 14.19C4.27003 15.36 5.13003 16.37 6.08003 17.19C6.39003 17.46 6.43003 17.93 6.16003 18.25C6.02003 18.42 5.81003 18.51 5.60003 18.51Z" />
< path d = "M12 21.02C10.67 21.02 9.37 20.75 8.12 20.22C7.74 20.06 7.56 19.62 7.72 19.24C7.88 18.86 8.32 18.68 8.7 18.84C9.76 19.29 10.87 19.52 11.99 19.52C15.22 19.52 18.31 17.58 20.47 14.19C21.22 13.02 21.22 10.98 20.47 9.81C20.16 9.32 19.82 8.85 19.46 8.41C19.2 8.09 19.25 7.62 19.57 7.35C19.89 7.09 20.36 7.13 20.63 7.46C21.02 7.94 21.4 8.46 21.74 9C22.8 10.65 22.8 13.34 21.74 15C19.3 18.82 15.75 21.02 12 21.02Z" />
< path d = "M12.69 16.2701C12.34 16.2701 12.02 16.0201 11.95 15.6601C11.87 15.2501 12.14 14.8601 12.55 14.7901C13.65 14.5901 14.57 13.6701 14.77 12.5701C14.85 12.1601 15.24 11.9001 15.65 11.9701C16.06 12.0501 16.33 12.4401 16.25 12.8501C15.93 14.5801 14.55 15.9501 12.83 16.2701C12.78 16.2601 12.74 16.2701 12.69 16.2701Z" />
< path d = "M2 22.75C1.81 22.75 1.62 22.68 1.47 22.53C1.18 22.24 1.18 21.76 1.47 21.47L8.94 14C9.23 13.71 9.71 13.71 10 14C10.29 14.29 10.29 14.77 10 15.06L2.53 22.53C2.38 22.68 2.19 22.75 2 22.75Z" />
< path d = "M14.53 10.2199C14.34 10.2199 14.15 10.1499 14 9.99994C13.71 9.70994 13.71 9.22994 14 8.93994L21.47 1.46994C21.76 1.17994 22.24 1.17994 22.53 1.46994C22.82 1.75994 22.82 2.23994 22.53 2.52994L15.06 9.99994C14.91 10.1499 14.72 10.2199 14.53 10.2199Z" />
</ svg >
</ button >
< span class = "htooltip" role = "tooltip" aria-hidden = "true" >Show password</ span >
</ span >
</ div >
</ div >
View full source
API reference React <PasswordInput> renders the whole field: the Field, the input, the toggle with its tooltip, and, with strength, the meter, word, and hint. Other props are the <input>'s attributes, such as autoComplete.
HTML A <div class="hpassword"> holding an <input class="hinput" type="password"> and the toggle. Load password.css, input.css, field.css, and tooltip.css; meter.css for the strength.
It needs a script for the toggle, revealing and resetting the details, and the strength. The strength rule and wording belong to the app. See Password input's full contract .
Accessibility The toggle's name stays "Show password" and aria-pressed reports whether the password shows, so its name doesn't change under the user. The tooltip is only the visual label: it carries aria-hidden="true" and no id, an exception to Tooltip 's usual contract, so screen readers don't hear the name twice. The input's aria-describedby points at the word and hint, read on focus. The word is a polite live region, so "Too weak", "Medium", and "Strong" are announced as they change, once per level rather than per keystroke.