Password Input

Obscured text input.

html

<label class="pw" for="pw-1">
  <span class="pw__label">Password <span class="pw__req">*</span></span>
  <span class="pw__row">
    <input class="pw__input" id="pw-1" type="password" placeholder="Enter your password" autocomplete="current-password" style="--accent:#241430;" required>
    <span class="pw__reveal" tabindex="0" role="button" aria-label="Show password">&#128065;</span>
  </span>
</label>
<style>
.pw { display: block; font: 14px system-ui, sans-serif; color: #241430; max-width: 260px; }
.pw__label { display: block; margin-bottom: 6px; font-weight: 500; }
.pw__req { color: #241430; }
.pw__row { position: relative; display: block; }
.pw__input { width: 100%; box-sizing: border-box; padding: 10px 38px 10px 12px; font: inherit; color: #241430; background: #FAF7F2; border: 1.5px solid #24143040; border-radius: 8px; }
.pw__input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.pw__reveal { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); cursor: pointer; }
.pw__reveal:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
</style>

tailwind

<label class="block max-w-[260px] font-sans text-sm text-[#241430]" for="pw-tw-1">
  <span class="block mb-1.5 font-medium">Password <span>*</span></span>
  <span class="relative block">
    <input id="pw-tw-1" type="password" placeholder="Enter your password" autocomplete="current-password" required
      class="w-full box-border pl-3 pr-10 py-2.5 bg-[#FAF7F2] border-[1.5px] border-[#24143040] rounded-lg focus-visible:outline-none" style="border-color:#241430;">
    <span tabindex="0" role="button" aria-label="Show password" class="absolute right-2.5 top-1/2 -translate-y-1/2 cursor-pointer">&#128065;</span>
  </span>
</label>

react

export function PasswordInput({
  label = "Password",
  placeholder = "Enter your password",
  showToggle = true,
  accent = "#241430",
  required = true,
}) {
  return (
    <label style={{ display: "block", maxWidth: 260, fontFamily: "system-ui, sans-serif", fontSize: 14, color: "#241430" }}>
      <span style={{ display: "block", marginBottom: 6, fontWeight: 500 }}>{label}{required && " *"}</span>
      <span style={{ position: "relative", display: "block" }}>
        <input type="password" placeholder={placeholder} autoComplete="current-password" required={required} style={{
          width: "100%", boxSizing: "border-box", padding: "10px 38px 10px 12px", font: "inherit", color: "#241430",
          background: "#FAF7F2", border: `1.5px solid ${accent}`, borderRadius: 8,
        }} />
        {showToggle && (
          <span tabIndex={0} role="button" aria-label="Show password" style={{ position: "absolute", right: 10, top: "50%", transform: "translateY(-50%)", cursor: "pointer" }}>
            👁
          </span>
        )}
      </span>
    </label>
  );
}