# Masked API key field

> A hidden API key that decodes character by character when revealed, with a copy button and another to regenerate it.

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

## Where to use it

A read-only field for secret keys, as seen in developer dashboards. The key shows only its prefix and last four characters; the eye button decodes the rest with a short scramble that settles left to right. Copy swaps the icon for a tick with a tooltip, and Regenerate spins its arrow, flashes the field and scrambles in a new key.

The main color tints the environment tag, the active eye and the regenerate link. Use it in settings pages, webhook setups and integration screens, and connect the copy and regenerate handlers to your own API when you move it to production.

## Code

### HTML

```html
<div class="uvq06-ak"><div class="hd"><label for="uvq06-ak-in">Secret key</label><span class="tg"><i></i>Production</span></div><div class="fd"><input id="uvq06-ak-in" readonly spellcheck="false"><button type="button" class="ey" aria-pressed="false" aria-label="Show key"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path 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 cx="12" cy="12" r="3"/></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 3l18 18M10.6 5.6A9.6 9.6 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a17 17 0 0 1-2.8 3.6M6.6 6.6C3.9 8.3 2.5 12 2.5 12S6 18.5 12 18.5c1.8 0 3.3-.5 4.6-1.3M9.9 9.9a3 3 0 0 0 4.2 4.2"/></svg></button><button type="button" class="cp" aria-label="Copy key"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="8.5" y="8.5" width="11" height="11" rx="2.5"/><path d="M15.5 8.5V6.5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2"/></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg><span class="tt" aria-hidden="true">Copied</span></button></div><div class="ft"><span>Created 3 days ago · last used today</span><button type="button" class="rg"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M20 11a8 8 0 1 0-2.3 5.7M20 4.5V11h-6.5"/></svg><span>Regenerate</span></button></div><p class="sr" aria-live="polite"></p></div>
```

### CSS

```css
.uvq06-ak {
  --c1: #7c3aed;
  --c2: #ede9fe;
  --s: 16px;
  /* tamaño */
  --k: 1;
  /* velocidad */
  --fg: #1d1d1f;
  /* texto */
  --bg: #f5f5f7;
  /* fondo */
}

.uvq06-ak {
  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;
  width: 19em;
}

.uvq06-ak .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-ak .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .45em;
}

.uvq06-ak .hd label {
  font-size: .82em;
  font-weight: 650;
}

.uvq06-ak .tg {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .28em .6em;
  border-radius: 2em;
  font-size: .68em;
  font-weight: 700;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  background: color-mix(in srgb,var(--c1) 13%,transparent);
}

.uvq06-ak .tg i {
  width: .5em;
  height: .5em;
  border-radius: 50%;
  background: var(--c1);
  animation: uvq06-ak-p calc(2s / var(--k)) cubic-bezier(.25,.1,.25,1) infinite;
}

.uvq06-ak .fd {
  display: flex;
  align-items: center;
  gap: .1em;
  padding: 0 .3em 0 .85em;
  border-radius: .9em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
  transition: box-shadow calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ak .fd:focus-within {
  box-shadow: 0 0 0 2px var(--c1),0 0 0 6px color-mix(in srgb,var(--c1) 18%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
}

.uvq06-ak.flash .fd {
  animation: uvq06-ak-f calc(0.7s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ak input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  height: 3em;
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-size: .84em;
  letter-spacing: .02em;
  text-overflow: ellipsis;
}

.uvq06-ak .fd button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.2em;
  height: 2.2em;
  border-radius: .6em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .fd button:hover {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-ak .fd button:active {
  transform: scale(.88);
}

.uvq06-ak button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-ak .fd svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq06-ak .ey svg+svg,.uvq06-ak .ey[aria-pressed="true"] svg:first-child,.uvq06-ak .cp svg+svg,.uvq06-ak .cp.done svg:first-child {
  display: none;
}

.uvq06-ak .ey[aria-pressed="true"] svg+svg {
  display: block;
}

.uvq06-ak .ey[aria-pressed="true"] {
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
}

.uvq06-ak .cp.done svg+svg {
  display: block;
  color: #16a34a;
  animation: uvq06-ak-c calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .tt {
  position: absolute;
  bottom: calc(100% + .45em);
  left: 50%;
  padding: .3em .55em;
  border-radius: .45em;
  font-size: .68em;
  font-weight: 700;
  white-space: nowrap;
  color: var(--bg);
  background: var(--fg);
  opacity: 0;
  translate: -50% .3em;
  pointer-events: none;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),translate calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .cp.done .tt {
  opacity: 1;
  translate: -50% 0;
}

.uvq06-ak .ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5em;
  margin-top: .55em;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-ak .rg {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: .35em;
  flex: none;
  padding: .35em .6em;
  border-radius: .5em;
  font-weight: 700;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .rg:hover {
  background: color-mix(in srgb,var(--c1) 11%,transparent);
}

.uvq06-ak .rg:active {
  transform: scale(.95);
}

.uvq06-ak .rg svg {
  width: 1.15em;
  height: 1.15em;
}

.uvq06-ak .rg.spin svg {
  animation: uvq06-ak-r calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

@keyframes uvq06-ak-p {
  50% {
    opacity: .35;
  }
}

@keyframes uvq06-ak-c {
  from {
    transform: scale(.3) rotate(-30deg);
  }
}

@keyframes uvq06-ak-r {
  to {
    transform: rotate(360deg);
  }
}

@keyframes uvq06-ak-f {
  0% {
    box-shadow: 0 0 0 2px var(--c1),0 0 0 8px color-mix(in srgb,var(--c1) 25%,transparent);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-ak,.uvq06-ak *,.uvq06-ak *::before,.uvq06-ak *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
```

### JavaScript

```js
document.querySelectorAll(".uvq06-ak").forEach(el => {
  const i=el.querySelector("input"),ey=el.querySelector(".ey"),cp=el.querySelector(".cp"),rg=el.querySelector(".rg"),sr=el.querySelector("p.sr");const AB="abcdefghijklmnopqrstuvwxyz0123456789",G="#%&*+=?@$<>";let key="",show=false,raf=0,tt=0;
const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;
const gen=()=>"sk_live_"+Array.from({length:24},()=>AB[Math.floor(Math.random()*AB.length)]).join("");
const mask=k=>k.slice(0,8)+"•".repeat(12)+k.slice(-4);
const scr=(to,ms)=>{cancelAnimationFrame(raf);const t0=performance.now();const tick=now=>{const p=ms?Math.min(1,(now-t0)/ms):1,n=Math.floor(p*to.length);let s="";for(let k=0;k<to.length;k++)s+=k<n||k<8?to[k]:G[Math.floor(Math.random()*G.length)];i.value=s;if(p<1)raf=requestAnimationFrame(tick)};raf=requestAnimationFrame(tick)};
const view=()=>scr(show?key:mask(key),rm?0:show?560:240);
ey.addEventListener("click",()=>{show=!show;ey.setAttribute("aria-pressed",String(show));ey.setAttribute("aria-label",show?"Hide key":"Show key");view()});
cp.addEventListener("click",()=>{navigator.clipboard?.writeText(key).catch(()=>{});cp.classList.add("done");sr.textContent="Key copied";clearTimeout(tt);tt=setTimeout(()=>{cp.classList.remove("done");sr.textContent=""},1600)});
rg.addEventListener("click",()=>{key=gen();rg.classList.remove("spin");el.classList.remove("flash");void el.offsetWidth;rg.classList.add("spin");el.classList.add("flash");sr.textContent="New key generated";view()});
key=gen();i.value=mask(key);return()=>{cancelAnimationFrame(raf);clearTimeout(tt)}
});
```

### 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 = `
.uvq06-ak {
  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;
  width: 19em;
}

.uvq06-ak .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-ak .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .45em;
}

.uvq06-ak .hd label {
  font-size: .82em;
  font-weight: 650;
}

.uvq06-ak .tg {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .28em .6em;
  border-radius: 2em;
  font-size: .68em;
  font-weight: 700;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  background: color-mix(in srgb,var(--c1) 13%,transparent);
}

.uvq06-ak .tg i {
  width: .5em;
  height: .5em;
  border-radius: 50%;
  background: var(--c1);
  animation: uvq06-ak-p calc(2s / var(--k)) cubic-bezier(.25,.1,.25,1) infinite;
}

.uvq06-ak .fd {
  display: flex;
  align-items: center;
  gap: .1em;
  padding: 0 .3em 0 .85em;
  border-radius: .9em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
  transition: box-shadow calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ak .fd:focus-within {
  box-shadow: 0 0 0 2px var(--c1),0 0 0 6px color-mix(in srgb,var(--c1) 18%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
}

.uvq06-ak.flash .fd {
  animation: uvq06-ak-f calc(0.7s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ak input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  height: 3em;
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-size: .84em;
  letter-spacing: .02em;
  text-overflow: ellipsis;
}

.uvq06-ak .fd button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.2em;
  height: 2.2em;
  border-radius: .6em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .fd button:hover {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-ak .fd button:active {
  transform: scale(.88);
}

.uvq06-ak button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-ak .fd svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq06-ak .ey svg+svg,.uvq06-ak .ey[aria-pressed="true"] svg:first-child,.uvq06-ak .cp svg+svg,.uvq06-ak .cp.done svg:first-child {
  display: none;
}

.uvq06-ak .ey[aria-pressed="true"] svg+svg {
  display: block;
}

.uvq06-ak .ey[aria-pressed="true"] {
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
}

.uvq06-ak .cp.done svg+svg {
  display: block;
  color: #16a34a;
  animation: uvq06-ak-c calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .tt {
  position: absolute;
  bottom: calc(100% + .45em);
  left: 50%;
  padding: .3em .55em;
  border-radius: .45em;
  font-size: .68em;
  font-weight: 700;
  white-space: nowrap;
  color: var(--bg);
  background: var(--fg);
  opacity: 0;
  translate: -50% .3em;
  pointer-events: none;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),translate calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .cp.done .tt {
  opacity: 1;
  translate: -50% 0;
}

.uvq06-ak .ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5em;
  margin-top: .55em;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-ak .rg {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: .35em;
  flex: none;
  padding: .35em .6em;
  border-radius: .5em;
  font-weight: 700;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .rg:hover {
  background: color-mix(in srgb,var(--c1) 11%,transparent);
}

.uvq06-ak .rg:active {
  transform: scale(.95);
}

.uvq06-ak .rg svg {
  width: 1.15em;
  height: 1.15em;
}

.uvq06-ak .rg.spin svg {
  animation: uvq06-ak-r calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

@keyframes uvq06-ak-p {
  50% {
    opacity: .35;
  }
}

@keyframes uvq06-ak-c {
  from {
    transform: scale(.3) rotate(-30deg);
  }
}

@keyframes uvq06-ak-r {
  to {
    transform: rotate(360deg);
  }
}

@keyframes uvq06-ak-f {
  0% {
    box-shadow: 0 0 0 2px var(--c1),0 0 0 8px color-mix(in srgb,var(--c1) 25%,transparent);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-ak,.uvq06-ak *,.uvq06-ak *::before,.uvq06-ak *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// 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 i=el.querySelector("input"),ey=el.querySelector(".ey"),cp=el.querySelector(".cp"),rg=el.querySelector(".rg"),sr=el.querySelector("p.sr");const AB="abcdefghijklmnopqrstuvwxyz0123456789",G="#%&*+=?@$<>";let key="",show=false,raf=0,tt=0;
const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;
const gen=()=>"sk_live_"+Array.from({length:24},()=>AB[Math.floor(Math.random()*AB.length)]).join("");
const mask=k=>k.slice(0,8)+"•".repeat(12)+k.slice(-4);
const scr=(to,ms)=>{cancelAnimationFrame(raf);const t0=performance.now();const tick=now=>{const p=ms?Math.min(1,(now-t0)/ms):1,n=Math.floor(p*to.length);let s="";for(let k=0;k<to.length;k++)s+=k<n||k<8?to[k]:G[Math.floor(Math.random()*G.length)];i.value=s;if(p<1)raf=requestAnimationFrame(tick)};raf=requestAnimationFrame(tick)};
const view=()=>scr(show?key:mask(key),rm?0:show?560:240);
ey.addEventListener("click",()=>{show=!show;ey.setAttribute("aria-pressed",String(show));ey.setAttribute("aria-label",show?"Hide key":"Show key");view()});
cp.addEventListener("click",()=>{navigator.clipboard?.writeText(key).catch(()=>{});cp.classList.add("done");sr.textContent="Key copied";clearTimeout(tt);tt=setTimeout(()=>{cp.classList.remove("done");sr.textContent=""},1600)});
rg.addEventListener("click",()=>{key=gen();rg.classList.remove("spin");el.classList.remove("flash");void el.offsetWidth;rg.classList.add("spin");el.classList.add("flash");sr.textContent="New key generated";view()});
key=gen();i.value=mask(key);return()=>{cancelAnimationFrame(raf);clearTimeout(tt)}
}

export default function InApiKey() {
  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": "#7c3aed",
          "--c2": "#ede9fe",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-ak"><div className="hd"><label htmlFor="uvq06-ak-in">Secret key</label><span className="tg"><i></i>Production</span></div><div className="fd"><input id="uvq06-ak-in" readOnly={true} spellCheck="false" /><button type="button" className="ey" aria-pressed="false" aria-label="Show key"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path 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 cx="12" cy="12" r="3" /></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M3 3l18 18M10.6 5.6A9.6 9.6 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a17 17 0 0 1-2.8 3.6M6.6 6.6C3.9 8.3 2.5 12 2.5 12S6 18.5 12 18.5c1.8 0 3.3-.5 4.6-1.3M9.9 9.9a3 3 0 0 0 4.2 4.2" /></svg></button><button type="button" className="cp" aria-label="Copy key"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><rect x="8.5" y="8.5" width="11" height="11" rx="2.5" /><path d="M15.5 8.5V6.5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2" /></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5" /></svg><span className="tt" aria-hidden="true">Copied</span></button></div><div className="ft"><span>Created 3 days ago · last used today</span><button type="button" className="rg"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M20 11a8 8 0 1 0-2.3 5.7M20 4.5V11h-6.5" /></svg><span>Regenerate</span></button></div><p className="sr" aria-live="polite"></p></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 “Masked API key field” block (Inputs) from AIMRAN Library to my project.

## What it is
A hidden API key that decodes character by character when revealed, with a copy button and another to regenerate it.

## Chosen settings
- Main color: #7c3aed
- Secondary color: #ede9fe
- Size: 16px (from 12 to 24px)
- Speed: 1x (from 0.5 to 2x)
- Text: "Clave secreta"

## 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 = `
.uvq06-ak {
  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;
  width: 19em;
}

.uvq06-ak .sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.uvq06-ak .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .45em;
}

.uvq06-ak .hd label {
  font-size: .82em;
  font-weight: 650;
}

.uvq06-ak .tg {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .28em .6em;
  border-radius: 2em;
  font-size: .68em;
  font-weight: 700;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  background: color-mix(in srgb,var(--c1) 13%,transparent);
}

.uvq06-ak .tg i {
  width: .5em;
  height: .5em;
  border-radius: 50%;
  background: var(--c1);
  animation: uvq06-ak-p calc(2s / var(--k)) cubic-bezier(.25,.1,.25,1) infinite;
}

.uvq06-ak .fd {
  display: flex;
  align-items: center;
  gap: .1em;
  padding: 0 .3em 0 .85em;
  border-radius: .9em;
  background: color-mix(in srgb,var(--fg) 3%,var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb,var(--fg) 12%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
  transition: box-shadow calc(0.25s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ak .fd:focus-within {
  box-shadow: 0 0 0 2px var(--c1),0 0 0 6px color-mix(in srgb,var(--c1) 18%,transparent),0 14px 34px -24px rgba(0,0,0,.45);
}

.uvq06-ak.flash .fd {
  animation: uvq06-ak-f calc(0.7s / var(--k)) cubic-bezier(.25,.1,.25,1);
}

.uvq06-ak input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font: inherit;
  color: var(--fg);
  height: 3em;
  font-family: ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  font-size: .84em;
  letter-spacing: .02em;
  text-overflow: ellipsis;
}

.uvq06-ak .fd button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 2.2em;
  height: 2.2em;
  border-radius: .6em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),color calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .fd button:hover {
  color: var(--fg);
  background: color-mix(in srgb,var(--fg) 6%,transparent);
}

.uvq06-ak .fd button:active {
  transform: scale(.88);
}

.uvq06-ak button:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 3px;
}

.uvq06-ak .fd svg {
  width: 1.1em;
  height: 1.1em;
}

.uvq06-ak .ey svg+svg,.uvq06-ak .ey[aria-pressed="true"] svg:first-child,.uvq06-ak .cp svg+svg,.uvq06-ak .cp.done svg:first-child {
  display: none;
}

.uvq06-ak .ey[aria-pressed="true"] svg+svg {
  display: block;
}

.uvq06-ak .ey[aria-pressed="true"] {
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
}

.uvq06-ak .cp.done svg+svg {
  display: block;
  color: #16a34a;
  animation: uvq06-ak-c calc(0.4s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .tt {
  position: absolute;
  bottom: calc(100% + .45em);
  left: 50%;
  padding: .3em .55em;
  border-radius: .45em;
  font-size: .68em;
  font-weight: 700;
  white-space: nowrap;
  color: var(--bg);
  background: var(--fg);
  opacity: 0;
  translate: -50% .3em;
  pointer-events: none;
  transition: opacity calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),translate calc(0.3s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .cp.done .tt {
  opacity: 1;
  translate: -50% 0;
}

.uvq06-ak .ft {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5em;
  margin-top: .55em;
  font-size: .72em;
  color: color-mix(in srgb,var(--fg) 55%,transparent);
}

.uvq06-ak .rg {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  gap: .35em;
  flex: none;
  padding: .35em .6em;
  border-radius: .5em;
  font-weight: 700;
  color: color-mix(in srgb,var(--c1) 70%,var(--fg));
  transition: background calc(0.2s / var(--k)) cubic-bezier(.25,.1,.25,1),transform calc(0.25s / var(--k)) cubic-bezier(.34,1.56,.64,1);
}

.uvq06-ak .rg:hover {
  background: color-mix(in srgb,var(--c1) 11%,transparent);
}

.uvq06-ak .rg:active {
  transform: scale(.95);
}

.uvq06-ak .rg svg {
  width: 1.15em;
  height: 1.15em;
}

.uvq06-ak .rg.spin svg {
  animation: uvq06-ak-r calc(0.6s / var(--k)) cubic-bezier(.22,1,.36,1);
}

@keyframes uvq06-ak-p {
  50% {
    opacity: .35;
  }
}

@keyframes uvq06-ak-c {
  from {
    transform: scale(.3) rotate(-30deg);
  }
}

@keyframes uvq06-ak-r {
  to {
    transform: rotate(360deg);
  }
}

@keyframes uvq06-ak-f {
  0% {
    box-shadow: 0 0 0 2px var(--c1),0 0 0 8px color-mix(in srgb,var(--c1) 25%,transparent);
  }
}

@media (prefers-reduced-motion:reduce) {
  .uvq06-ak,.uvq06-ak *,.uvq06-ak *::before,.uvq06-ak *::after {
    animation-duration: .01ms!important;
    animation-iteration-count: 1!important;
    transition-duration: .01ms!important;
  }
}
`;

// 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 i=el.querySelector("input"),ey=el.querySelector(".ey"),cp=el.querySelector(".cp"),rg=el.querySelector(".rg"),sr=el.querySelector("p.sr");const AB="abcdefghijklmnopqrstuvwxyz0123456789",G="#%&*+=?@$<>";let key="",show=false,raf=0,tt=0;
const rm=matchMedia("(prefers-reduced-motion: reduce)").matches;
const gen=()=>"sk_live_"+Array.from({length:24},()=>AB[Math.floor(Math.random()*AB.length)]).join("");
const mask=k=>k.slice(0,8)+"•".repeat(12)+k.slice(-4);
const scr=(to,ms)=>{cancelAnimationFrame(raf);const t0=performance.now();const tick=now=>{const p=ms?Math.min(1,(now-t0)/ms):1,n=Math.floor(p*to.length);let s="";for(let k=0;k<to.length;k++)s+=k<n||k<8?to[k]:G[Math.floor(Math.random()*G.length)];i.value=s;if(p<1)raf=requestAnimationFrame(tick)};raf=requestAnimationFrame(tick)};
const view=()=>scr(show?key:mask(key),rm?0:show?560:240);
ey.addEventListener("click",()=>{show=!show;ey.setAttribute("aria-pressed",String(show));ey.setAttribute("aria-label",show?"Hide key":"Show key");view()});
cp.addEventListener("click",()=>{navigator.clipboard?.writeText(key).catch(()=>{});cp.classList.add("done");sr.textContent="Key copied";clearTimeout(tt);tt=setTimeout(()=>{cp.classList.remove("done");sr.textContent=""},1600)});
rg.addEventListener("click",()=>{key=gen();rg.classList.remove("spin");el.classList.remove("flash");void el.offsetWidth;rg.classList.add("spin");el.classList.add("flash");sr.textContent="New key generated";view()});
key=gen();i.value=mask(key);return()=>{cancelAnimationFrame(raf);clearTimeout(tt)}
}

export default function InApiKey() {
  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": "#7c3aed",
          "--c2": "#ede9fe",
          "--s": "16px",
          "--k": "1",
          "--fg": "#1d1d1f",
          "--bg": "#f5f5f7",
        } as CSSProperties}
      >
        <div className="uvq06-ak"><div className="hd"><label htmlFor="uvq06-ak-in">Secret key</label><span className="tg"><i></i>Production</span></div><div className="fd"><input id="uvq06-ak-in" readOnly={true} spellCheck="false" /><button type="button" className="ey" aria-pressed="false" aria-label="Show key"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path 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 cx="12" cy="12" r="3" /></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M3 3l18 18M10.6 5.6A9.6 9.6 0 0 1 12 5.5c6 0 9.5 6.5 9.5 6.5a17 17 0 0 1-2.8 3.6M6.6 6.6C3.9 8.3 2.5 12 2.5 12S6 18.5 12 18.5c1.8 0 3.3-.5 4.6-1.3M9.9 9.9a3 3 0 0 0 4.2 4.2" /></svg></button><button type="button" className="cp" aria-label="Copy key"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><rect x="8.5" y="8.5" width="11" height="11" rx="2.5" /><path d="M15.5 8.5V6.5a2 2 0 0 0-2-2h-7a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h2" /></svg><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5" /></svg><span className="tt" aria-hidden="true">Copied</span></button></div><div className="ft"><span>Created 3 days ago · last used today</span><button type="button" className="rg"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><path d="M20 11a8 8 0 1 0-2.3 5.7M20 4.5V11h-6.5" /></svg><span>Regenerate</span></button></div><p className="sr" aria-live="polite"></p></div>
      </div>
    </>
  );
}
```

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