Skip to main content

Password Input

A password field with a show/hide toggle and optional strength indicator.

Components used​

Input · Button

Preview · Password Input

Code​

<div>
<label style="display:block;font-size:0.8125rem;font-weight:500;margin-bottom:0.375rem">
Password
</label>
<div style="position:relative">
<input id="password" type="password"
placeholder="••••••••"
style="width:100%;padding:0.5625rem 2.75rem 0.5625rem 0.875rem;
border:1px solid var(--border);border-radius:7px;
font-size:0.875rem;box-sizing:border-box" />
<button type="button"
class="ghost icon small"
style="position:absolute;right:6px;top:50%;transform:translateY(-50%)"
aria-label="Show password"
onclick="
const inp = document.getElementById('password');
this.setAttribute('aria-label', inp.type === 'password' ? 'Hide password' : 'Show password');
inp.type = inp.type === 'password' ? 'text' : 'password';
">
<svg width="14" height="14" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2">
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/>
<circle cx="12" cy="12" r="3"/>
</svg>
</button>
</div>
</div>

Props​

PropTypeDefaultDescription
labelstring—Field label
valuestring''Controlled value
placeholderstring'••••••••'Input placeholder
showStrengthbooleanfalseShow password strength bar below the field
errorstring—Error message
disabledbooleanfalseDisabled state
onChange / (valueChange)(v: string) => void—Change handler
Version history

See the Changelog for version history and breaking changes.