# Password reveal with line

> An eye button reveals the password, and a line draws across the icon to show it is visible.

- Category: [Inputs](https://library.aimran.es/components/inputs)
- Built with: HTML + CSS
- Live editor: https://library.aimran.es/blocks/uv-in2-password
- Library: AIMRAN Library (https://library.aimran.es), free, no sign-up, by Aimran Oukham

## Where to use it

Letting people see what they typed saves a lot of failed logins, especially on phones. Use it on the sign-in page of an app, when creating an account or in the Wi-Fi step of a smart device setup. The slash over the eye makes the state obvious. A show-password input in HTML, CSS and a little JavaScript.

Give the eye button an accessible name such as “Show password”, so screen readers can announce it. On a sign-up form, pair it with a short hint about the rules instead of an error after submitting.

## Code

### HTML

```html
<label class="uv-in2p"><input type="password" placeholder="Password" value="secreto123"><button class="ey"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"><path d="M2 12s3.8-6 10-6 10 6 10 6-3.8 6-10 6-10-6-10-6z"/><circle cx="12" cy="12" r="2.8"/><path class="sl" d="M4 20L20 4"/></svg></button></label>
```

### CSS

```css
.uv-in2p {
  --c1: #0071e3;
  --c2: #8ec5ff;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uv-in2p {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: block;
  width: 16em;
}

.uv-in2p input {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  width: 100%;
  box-sizing: border-box;
  padding: .9em 3em .9em 1em;
  font-size: var(--s);
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 5%,transparent);
  border: 0;
  outline: 0;
  border-radius: .85em;
  box-shadow: inset 0 0 0 1.6px color-mix(in srgb,var(--fg) 10%,transparent);
  transition: box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p input:focus {
  box-shadow: inset 0 0 0 1.8px var(--c1),0 0 0 4px color-mix(in srgb,var(--c1) 15%,transparent);
}

.uv-in2p .ey {
  position: absolute;
  right: .45em;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  border: 0;
  border-radius: 50%;
  background: none;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  cursor: pointer;
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p .ey:hover {
  color: var(--c1);
  background: color-mix(in srgb,var(--c1) 10%,transparent);
}

.uv-in2p .ey svg {
  width: 1.25em;
  height: 1.25em;
  overflow: visible;
}

.uv-in2p .sl {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p.show .sl {
  stroke-dashoffset: 0;
}

.uv-in2p.show .ey {
  color: var(--c1);
}
```

### JavaScript

```js
document.querySelectorAll(".uv-in2p").forEach(el => {
  const b=el.querySelector(".ey"),i=el.querySelector("input");b.addEventListener("click",e=>{e.preventDefault();el.classList.toggle("show");i.type=el.classList.contains("show")?"text":"password"})
});
```

### React

```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uv-in2p {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: block;
  width: 16em;
}

.uv-in2p input {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  width: 100%;
  box-sizing: border-box;
  padding: .9em 3em .9em 1em;
  font-size: var(--s);
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 5%,transparent);
  border: 0;
  outline: 0;
  border-radius: .85em;
  box-shadow: inset 0 0 0 1.6px color-mix(in srgb,var(--fg) 10%,transparent);
  transition: box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p input:focus {
  box-shadow: inset 0 0 0 1.8px var(--c1),0 0 0 4px color-mix(in srgb,var(--c1) 15%,transparent);
}

.uv-in2p .ey {
  position: absolute;
  right: .45em;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  border: 0;
  border-radius: 50%;
  background: none;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  cursor: pointer;
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p .ey:hover {
  color: var(--c1);
  background: color-mix(in srgb,var(--c1) 10%,transparent);
}

.uv-in2p .ey svg {
  width: 1.25em;
  height: 1.25em;
  overflow: visible;
}

.uv-in2p .sl {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p.show .sl {
  stroke-dashoffset: 0;
}

.uv-in2p.show .ey {
  color: var(--c1);
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const b=el.querySelector(".ey"),i=el.querySelector("input");b.addEventListener("click",e=>{e.preventDefault();el.classList.toggle("show");i.type=el.classList.contains("show")?"text":"password"})
}

export default function In2Password() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uv-in2p"><input type="password" placeholder="Password" value="secreto123" /><button className="ey"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round"><path d="M2 12s3.8-6 10-6 10 6 10 6-3.8 6-10 6-10-6-10-6z" /><circle cx="12" cy="12" r="2.8" /><path className="sl" d="M4 20L20 4" /></svg></button></label>
      </div>
    </>
  );
}
```

## Prompt for AI assistants

Paste this into ChatGPT, Claude, Cursor, v0 or Lovable to adapt the block to your stack (Tailwind, Vue, Svelte…):

````text
I want to add the “Password reveal with line” block (Inputs) from AIMRAN Library to my project.

## What it is
An eye button reveals the password, and a line draws across the icon to show it is visible.

## Chosen settings
- Main color: #0071e3
- Secondary color: #8ec5ff
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Password"

## What I need
1. Add it to my project with the same look and animation as the reference code: same sizes, colours, radii, shadows, timings and easing.
2. It is built with plain HTML and CSS (the reference wraps it in a React component with its CSS). If my project uses something else (Vue, Svelte, Astro, plain HTML…), translate it without losing any behaviour. If I use Tailwind, turn the styles into classes; if not, keep the CSS in its own file.
3. Expose the settings above as props (or CSS variables) with those values as defaults.
4. Make it work well on phones: nothing that depends only on hover, touch targets of at least 44 px and no overflow on 320 px screens.
5. Make it look right in light and dark mode.
6. Keep it accessible: semantic HTML, roles and aria-* where needed, visible focus and keyboard support.
7. Respect prefers-reduced-motion: with reduced motion, no big animations but the same end result.

## Reference code
```tsx
// @ts-nocheck: setup() es JavaScript del DOM sin tipos, el mismo de la pestaña JS.
import { useEffect, useRef, type CSSProperties } from "react";

const css = `
.uv-in2p {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  font-size: var(--s);
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: block;
  width: 16em;
}

.uv-in2p input {
  font-family: -apple-system,BlinkMacSystemFont,"SF Pro Text","Inter",system-ui,sans-serif;
  width: 100%;
  box-sizing: border-box;
  padding: .9em 3em .9em 1em;
  font-size: var(--s);
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 5%,transparent);
  border: 0;
  outline: 0;
  border-radius: .85em;
  box-shadow: inset 0 0 0 1.6px color-mix(in srgb,var(--fg) 10%,transparent);
  transition: box-shadow calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p input:focus {
  box-shadow: inset 0 0 0 1.8px var(--c1),0 0 0 4px color-mix(in srgb,var(--c1) 15%,transparent);
}

.uv-in2p .ey {
  position: absolute;
  right: .45em;
  top: 50%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  border: 0;
  border-radius: 50%;
  background: none;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  cursor: pointer;
  transition: color calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1),background calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p .ey:hover {
  color: var(--c1);
  background: color-mix(in srgb,var(--c1) 10%,transparent);
}

.uv-in2p .ey svg {
  width: 1.25em;
  height: 1.25em;
  overflow: visible;
}

.uv-in2p .sl {
  stroke-dasharray: 24;
  stroke-dashoffset: 24;
  transition: stroke-dashoffset calc(0.35s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uv-in2p.show .sl {
  stroke-dashoffset: 0;
}

.uv-in2p.show .ey {
  color: var(--c1);
}
`;

// Interacción en JavaScript del DOM: la misma que en la pestaña JS.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setup(el: any) {
  const b=el.querySelector(".ey"),i=el.querySelector("input");b.addEventListener("click",e=>{e.preventDefault();el.classList.toggle("show");i.type=el.classList.contains("show")?"text":"password"})
}

export default function In2Password() {
  const ref = useRef<HTMLDivElement>(null);

  useEffect(() => {
    const el = ref.current?.firstElementChild;
    return el ? setup(el) : undefined;
  }, []);

  return (
    <>
      <style>{css}</style>
      <div
        ref={ref} style={{
          "--c1": "#0071e3",
          "--c2": "#8ec5ff",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <label className="uv-in2p"><input type="password" placeholder="Password" value="secreto123" /><button className="ey"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.9" strokeLinecap="round"><path d="M2 12s3.8-6 10-6 10 6 10 6-3.8 6-10 6-10-6-10-6z" /><circle cx="12" cy="12" r="2.8" /><path className="sl" d="M4 20L20 4" /></svg></button></label>
      </div>
    </>
  );
}
```

Give me the complete final code, ready to paste, and tell me in one line where to put it in my project.
````
