# Live password requirements tooltip

> Focusing the password field opens a tooltip with a strength meter and rules that tick off as you type.

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

## Where to use it

A password field whose tooltip appears on focus or hover with a four step strength meter, a level label and four rules for length, uppercase, number and symbol. Each rule gets an animated check as soon as it is met, and the field is linked to the tooltip with aria-describedby. An eye button shows or hides the text. It fits sign up, reset and account settings.

The main color marks a strong password and checked rules, the second the middle level. Adapt the regular expressions in the script to your own policy and keep the list to four or five clear rules.

## Code

### HTML

```html
<div class="uvq08-pwd"><label for="uvq08-pwd-i">New password</label><span class="fw pk"><input id="uvq08-pwd-i" type="password" autocomplete="new-password" spellcheck="false" aria-describedby="uvq08-pwd-t"><button type="button" class="ey" aria-label="Show password" aria-pressed="false"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path class="or" d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z"/><circle class="or" cx="12" cy="12" r="3"/><path class="x" d="M4 4l16 16"/></svg></button><span class="tt" role="tooltip" id="uvq08-pwd-t" data-l="0"><span class="mt" aria-hidden="true"><i></i><i></i><i></i><i></i></span><span class="lv"><span>Start typing</span><span>Weak</span><span>Fair</span><span>Good</span><span>Strong</span></span><span class="ru" data-r="len"><i aria-hidden="true"></i>8 characters or more</span><span class="ru" data-r="up"><i aria-hidden="true"></i>One uppercase letter</span><span class="ru" data-r="num"><i aria-hidden="true"></i>One number</span><span class="ru" data-r="sym"><i aria-hidden="true"></i>One symbol</span></span></span></div>
```

### CSS

```css
.uvq08-pwd {
  --c1: #10b981;
  --c2: #f59e0b;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq08-pwd {
  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;
  display: grid;
  gap: .45em;
  width: 16em;
  padding-bottom: 10.4em;
}

.uvq08-pwd label {
  font-size: .85em;
  font-weight: 700;
}

.uvq08-pwd .fw {
  position: relative;
  display: block;
}

.uvq08-pwd input {
  box-sizing: border-box;
  width: 100%;
  height: 2.9em;
  padding: 0 3em 0 1em;
  border: 0;
  outline: 0;
  border-radius: .9em;
  font: inherit;
  letter-spacing: .05em;
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 8%,transparent),0 24px 48px -30px rgba(0,0,0,.45);
  transition: box-shadow calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd input:focus {
  box-shadow: 0 0 0 2px var(--c1);
}

.uvq08-pwd .ey {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .35em;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  translate: 0 -50%;
  border-radius: .7em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-pwd .ey svg {
  width: 1.2em;
  height: 1.2em;
}

.uvq08-pwd .ey .x {
  opacity: 0;
}

.uvq08-pwd .ey[aria-pressed="true"] .x {
  opacity: 1;
}

.uvq08-pwd .ey:hover {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq08-pwd .ey:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq08-pwd .tt {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + .8em);
  z-index: 3;
  display: grid;
  gap: .45em;
  padding: .85em .95em;
  border-radius: 1em;
  font-size: .82em;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  transform: translateY(-.4em);
  opacity: 0;
  visibility: hidden;
  transition: all calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd .tt::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: .7em;
  height: .7em;
  background: var(--fg);
  transform: translate(-50%,55%) rotate(45deg);
  border-radius: .15em 0 0 0;
}

.uvq08-pwd .fw:hover .tt,.uvq08-pwd .fw:focus-within .tt,.uvq08-pwd .fw.pk .tt {
  transform: none;
  opacity: 1;
  visibility: visible;
}

.uvq08-pwd .mt {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: .3em;
}

.uvq08-pwd .mt i {
  height: .3em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--bg) 22%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd [data-l="1"] .mt i:nth-child(-n+1) {
  background: #ef4444;
}

.uvq08-pwd [data-l="2"] .mt i:nth-child(-n+2) {
  background: var(--c2);
}

.uvq08-pwd [data-l="3"] .mt i:nth-child(-n+3) {
  background: #84cc16;
}

.uvq08-pwd [data-l="4"] .mt i {
  background: var(--c1);
}

.uvq08-pwd .lv {
  font-weight: 750;
  margin-bottom: .15em;
}

.uvq08-pwd .lv span {
  display: none;
}

.uvq08-pwd [data-l="0"] .lv span:nth-child(1),.uvq08-pwd [data-l="1"] .lv span:nth-child(2),.uvq08-pwd [data-l="2"] .lv span:nth-child(3),.uvq08-pwd [data-l="3"] .lv span:nth-child(4),.uvq08-pwd [data-l="4"] .lv span:nth-child(5) {
  display: inline;
}

.uvq08-pwd .ru {
  display: flex;
  align-items: center;
  gap: .55em;
  color: color-mix(in srgb,var(--bg) 70%,transparent);
  transition: color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd .ru i {
  position: relative;
  flex: none;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--bg) 45%,transparent);
  transition: all calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq08-pwd .ru.ok {
  color: var(--bg);
}

.uvq08-pwd .ru.ok i {
  background: var(--c1);
  box-shadow: none;
  transform: scale(1.1);
}

.uvq08-pwd .ru.ok i::after {
  content: "";
  position: absolute;
  left: .36em;
  top: .18em;
  width: .22em;
  height: .45em;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}
```

### JavaScript

```js
document.querySelectorAll(".uvq08-pwd").forEach(el => {
  const unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const inp=el.querySelector("input"),tt=el.querySelector(".tt"),ey=el.querySelector(".ey"),rs=[...el.querySelectorAll("[data-r]")];
const ck={len:s=>s.length>=8,up:s=>/[A-ZÁÉÍÓÚÑ]/.test(s),num:s=>/[0-9]/.test(s),sym:s=>/[^A-Za-z0-9 áéíóúüñÁÉÍÓÚÜÑ]/.test(s)};
const up=()=>{const s=inp.value;let n=0;rs.forEach(r=>{const ok=ck[r.dataset.r](s);r.classList.toggle("ok",ok);n+=ok?1:0});tt.dataset.l=String(s?Math.max(1,n):0)};
inp.addEventListener("input",up);ey.addEventListener("click",()=>{const show=inp.type==="password";inp.type=show?"text":"password";ey.setAttribute("aria-pressed",String(show))});up()
});
```

### 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 = `
.uvq08-pwd {
  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;
  display: grid;
  gap: .45em;
  width: 16em;
  padding-bottom: 10.4em;
}

.uvq08-pwd label {
  font-size: .85em;
  font-weight: 700;
}

.uvq08-pwd .fw {
  position: relative;
  display: block;
}

.uvq08-pwd input {
  box-sizing: border-box;
  width: 100%;
  height: 2.9em;
  padding: 0 3em 0 1em;
  border: 0;
  outline: 0;
  border-radius: .9em;
  font: inherit;
  letter-spacing: .05em;
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 8%,transparent),0 24px 48px -30px rgba(0,0,0,.45);
  transition: box-shadow calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd input:focus {
  box-shadow: 0 0 0 2px var(--c1);
}

.uvq08-pwd .ey {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .35em;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  translate: 0 -50%;
  border-radius: .7em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-pwd .ey svg {
  width: 1.2em;
  height: 1.2em;
}

.uvq08-pwd .ey .x {
  opacity: 0;
}

.uvq08-pwd .ey[aria-pressed="true"] .x {
  opacity: 1;
}

.uvq08-pwd .ey:hover {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq08-pwd .ey:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq08-pwd .tt {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + .8em);
  z-index: 3;
  display: grid;
  gap: .45em;
  padding: .85em .95em;
  border-radius: 1em;
  font-size: .82em;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  transform: translateY(-.4em);
  opacity: 0;
  visibility: hidden;
  transition: all calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd .tt::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: .7em;
  height: .7em;
  background: var(--fg);
  transform: translate(-50%,55%) rotate(45deg);
  border-radius: .15em 0 0 0;
}

.uvq08-pwd .fw:hover .tt,.uvq08-pwd .fw:focus-within .tt,.uvq08-pwd .fw.pk .tt {
  transform: none;
  opacity: 1;
  visibility: visible;
}

.uvq08-pwd .mt {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: .3em;
}

.uvq08-pwd .mt i {
  height: .3em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--bg) 22%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd [data-l="1"] .mt i:nth-child(-n+1) {
  background: #ef4444;
}

.uvq08-pwd [data-l="2"] .mt i:nth-child(-n+2) {
  background: var(--c2);
}

.uvq08-pwd [data-l="3"] .mt i:nth-child(-n+3) {
  background: #84cc16;
}

.uvq08-pwd [data-l="4"] .mt i {
  background: var(--c1);
}

.uvq08-pwd .lv {
  font-weight: 750;
  margin-bottom: .15em;
}

.uvq08-pwd .lv span {
  display: none;
}

.uvq08-pwd [data-l="0"] .lv span:nth-child(1),.uvq08-pwd [data-l="1"] .lv span:nth-child(2),.uvq08-pwd [data-l="2"] .lv span:nth-child(3),.uvq08-pwd [data-l="3"] .lv span:nth-child(4),.uvq08-pwd [data-l="4"] .lv span:nth-child(5) {
  display: inline;
}

.uvq08-pwd .ru {
  display: flex;
  align-items: center;
  gap: .55em;
  color: color-mix(in srgb,var(--bg) 70%,transparent);
  transition: color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd .ru i {
  position: relative;
  flex: none;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--bg) 45%,transparent);
  transition: all calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq08-pwd .ru.ok {
  color: var(--bg);
}

.uvq08-pwd .ru.ok i {
  background: var(--c1);
  box-shadow: none;
  transform: scale(1.1);
}

.uvq08-pwd .ru.ok i::after {
  content: "";
  position: absolute;
  left: .36em;
  top: .18em;
  width: .22em;
  height: .45em;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}
`;

// 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 unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const inp=el.querySelector("input"),tt=el.querySelector(".tt"),ey=el.querySelector(".ey"),rs=[...el.querySelectorAll("[data-r]")];
const ck={len:s=>s.length>=8,up:s=>/[A-ZÁÉÍÓÚÑ]/.test(s),num:s=>/[0-9]/.test(s),sym:s=>/[^A-Za-z0-9 áéíóúüñÁÉÍÓÚÜÑ]/.test(s)};
const up=()=>{const s=inp.value;let n=0;rs.forEach(r=>{const ok=ck[r.dataset.r](s);r.classList.toggle("ok",ok);n+=ok?1:0});tt.dataset.l=String(s?Math.max(1,n):0)};
inp.addEventListener("input",up);ey.addEventListener("click",()=>{const show=inp.type==="password";inp.type=show?"text":"password";ey.setAttribute("aria-pressed",String(show))});up()
}

export default function TipPasswordRules() {
  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": "#10b981",
          "--c2": "#f59e0b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-pwd"><label htmlFor="uvq08-pwd-i">New password</label><span className="fw pk"><input id="uvq08-pwd-i" type="password" autoComplete="new-password" spellCheck="false" aria-describedby="uvq08-pwd-t" /><button type="button" className="ey" aria-label="Show password" aria-pressed="false"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path className="or" d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z" /><circle className="or" cx="12" cy="12" r="3" /><path className="x" d="M4 4l16 16" /></svg></button><span className="tt" role="tooltip" id="uvq08-pwd-t" data-l="0"><span className="mt" aria-hidden="true"><i></i><i></i><i></i><i></i></span><span className="lv"><span>Start typing</span><span>Weak</span><span>Fair</span><span>Good</span><span>Strong</span></span><span className="ru" data-r="len"><i aria-hidden="true"></i>8 characters or more</span><span className="ru" data-r="up"><i aria-hidden="true"></i>One uppercase letter</span><span className="ru" data-r="num"><i aria-hidden="true"></i>One number</span><span className="ru" data-r="sym"><i aria-hidden="true"></i>One symbol</span></span></span></div>
      </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 “Live password requirements tooltip” block (Tooltips) from AIMRAN Library to my project.

## What it is
Focusing the password field opens a tooltip with a strength meter and rules that tick off as you type.

## Chosen settings
- Main color: #10b981
- Secondary color: #f59e0b
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Nueva contraseña"

## 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 = `
.uvq08-pwd {
  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;
  display: grid;
  gap: .45em;
  width: 16em;
  padding-bottom: 10.4em;
}

.uvq08-pwd label {
  font-size: .85em;
  font-weight: 700;
}

.uvq08-pwd .fw {
  position: relative;
  display: block;
}

.uvq08-pwd input {
  box-sizing: border-box;
  width: 100%;
  height: 2.9em;
  padding: 0 3em 0 1em;
  border: 0;
  outline: 0;
  border-radius: .9em;
  font: inherit;
  letter-spacing: .05em;
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 8%,transparent),0 24px 48px -30px rgba(0,0,0,.45);
  transition: box-shadow calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd input:focus {
  box-shadow: 0 0 0 2px var(--c1);
}

.uvq08-pwd .ey {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: absolute;
  right: .35em;
  top: 50%;
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  translate: 0 -50%;
  border-radius: .7em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq08-pwd .ey svg {
  width: 1.2em;
  height: 1.2em;
}

.uvq08-pwd .ey .x {
  opacity: 0;
}

.uvq08-pwd .ey[aria-pressed="true"] .x {
  opacity: 1;
}

.uvq08-pwd .ey:hover {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq08-pwd .ey:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq08-pwd .tt {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + .8em);
  z-index: 3;
  display: grid;
  gap: .45em;
  padding: .85em .95em;
  border-radius: 1em;
  font-size: .82em;
  color: var(--bg);
  background: var(--fg);
  box-shadow: 0 .8em 1.6em -.6em rgba(0,0,0,.45);
  transform: translateY(-.4em);
  opacity: 0;
  visibility: hidden;
  transition: all calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd .tt::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: .7em;
  height: .7em;
  background: var(--fg);
  transform: translate(-50%,55%) rotate(45deg);
  border-radius: .15em 0 0 0;
}

.uvq08-pwd .fw:hover .tt,.uvq08-pwd .fw:focus-within .tt,.uvq08-pwd .fw.pk .tt {
  transform: none;
  opacity: 1;
  visibility: visible;
}

.uvq08-pwd .mt {
  display: grid;
  grid-template-columns: repeat(4,1fr);
  gap: .3em;
}

.uvq08-pwd .mt i {
  height: .3em;
  border-radius: 1em;
  background: color-mix(in srgb,var(--bg) 22%,transparent);
  transition: background calc(0.3s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd [data-l="1"] .mt i:nth-child(-n+1) {
  background: #ef4444;
}

.uvq08-pwd [data-l="2"] .mt i:nth-child(-n+2) {
  background: var(--c2);
}

.uvq08-pwd [data-l="3"] .mt i:nth-child(-n+3) {
  background: #84cc16;
}

.uvq08-pwd [data-l="4"] .mt i {
  background: var(--c1);
}

.uvq08-pwd .lv {
  font-weight: 750;
  margin-bottom: .15em;
}

.uvq08-pwd .lv span {
  display: none;
}

.uvq08-pwd [data-l="0"] .lv span:nth-child(1),.uvq08-pwd [data-l="1"] .lv span:nth-child(2),.uvq08-pwd [data-l="2"] .lv span:nth-child(3),.uvq08-pwd [data-l="3"] .lv span:nth-child(4),.uvq08-pwd [data-l="4"] .lv span:nth-child(5) {
  display: inline;
}

.uvq08-pwd .ru {
  display: flex;
  align-items: center;
  gap: .55em;
  color: color-mix(in srgb,var(--bg) 70%,transparent);
  transition: color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq08-pwd .ru i {
  position: relative;
  flex: none;
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb,var(--bg) 45%,transparent);
  transition: all calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq08-pwd .ru.ok {
  color: var(--bg);
}

.uvq08-pwd .ru.ok i {
  background: var(--c1);
  box-shadow: none;
  transform: scale(1.1);
}

.uvq08-pwd .ru.ok i::after {
  content: "";
  position: absolute;
  left: .36em;
  top: .18em;
  width: .22em;
  height: .45em;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  rotate: 45deg;
}
`;

// 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 unpk=()=>{el.classList.remove("pk");el.querySelectorAll(".pk").forEach(x=>x.classList.remove("pk"))};el.addEventListener("pointerover",unpk,{once:true});el.addEventListener("focusin",unpk,{once:true});const inp=el.querySelector("input"),tt=el.querySelector(".tt"),ey=el.querySelector(".ey"),rs=[...el.querySelectorAll("[data-r]")];
const ck={len:s=>s.length>=8,up:s=>/[A-ZÁÉÍÓÚÑ]/.test(s),num:s=>/[0-9]/.test(s),sym:s=>/[^A-Za-z0-9 áéíóúüñÁÉÍÓÚÜÑ]/.test(s)};
const up=()=>{const s=inp.value;let n=0;rs.forEach(r=>{const ok=ck[r.dataset.r](s);r.classList.toggle("ok",ok);n+=ok?1:0});tt.dataset.l=String(s?Math.max(1,n):0)};
inp.addEventListener("input",up);ey.addEventListener("click",()=>{const show=inp.type==="password";inp.type=show?"text":"password";ey.setAttribute("aria-pressed",String(show))});up()
}

export default function TipPasswordRules() {
  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": "#10b981",
          "--c2": "#f59e0b",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq08-pwd"><label htmlFor="uvq08-pwd-i">New password</label><span className="fw pk"><input id="uvq08-pwd-i" type="password" autoComplete="new-password" spellCheck="false" aria-describedby="uvq08-pwd-t" /><button type="button" className="ey" aria-label="Show password" aria-pressed="false"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path className="or" d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z" /><circle className="or" cx="12" cy="12" r="3" /><path className="x" d="M4 4l16 16" /></svg></button><span className="tt" role="tooltip" id="uvq08-pwd-t" data-l="0"><span className="mt" aria-hidden="true"><i></i><i></i><i></i><i></i></span><span className="lv"><span>Start typing</span><span>Weak</span><span>Fair</span><span>Good</span><span>Strong</span></span><span className="ru" data-r="len"><i aria-hidden="true"></i>8 characters or more</span><span className="ru" data-r="up"><i aria-hidden="true"></i>One uppercase letter</span><span className="ru" data-r="num"><i aria-hidden="true"></i>One number</span><span className="ru" data-r="sym"><i aria-hidden="true"></i>One symbol</span></span></span></div>
      </div>
    </>
  );
}
```

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