Rendimiento
Requiere atenciónFrecuencia de fotogramas: 60 fps de media, p5 59.9 · Tareas largas: 0 tareas, 0 ms en total, la más larga 0 ms · Código gzip 9.7 KB · En ejecución 158 KB
One-time codeMITCampoBencho
Componente React de Campo de Lorenzo Cabra. Recopilado sin cambios de Bencho bajo la licencia MIT y mostrado aquí en directo.
Informe de calidad
La nota y la puntuación proceden de comprobaciones automáticas hechas en la compilación o en las pruebas. Si una comprobación no se ejecutó, se marca Como no comprobada: nunca se inventan cifras.
Frecuencia de fotogramas: 60 fps de media, p5 59.9 · Tareas largas: 0 tareas, 0 ms en total, la más larga 0 ms · Código gzip 9.7 KB · En ejecución 158 KB
Problemas 0 · Lector de pantalla: Correcto
Sin movimiento continuo
Sin desbordamiento
La frecuencia de fotogramas y las tareas largas se midieron en Chromium sin interfaz, con WebGL por software. Solo son comparables entre componentes de este sitio y no representan un dispositivo real.
No aplica: no hay animación visible en reposo. Las animaciones que se activan al pasar el cursor no se probaron.
No hay incumplimientos de axe-core.

Comprobado el 15 nov 2026 · Las cifras salen de un script automatico, no de ejemplos escritos a mano.
Se muestra a tamaño real.
La copia empieza con el aviso de licencia. Consérvalo al usar el código.
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── Bencho tokens ─────────────────────────────────────────
The custom properties the free blocks read, at the values
bencho.dev draws them with. Light by default; dark under
[data-theme="dark"] on any ancestor, or automatically with
the system setting unless [data-theme="light"] says otherwise.
Map these to your own theme rather than keeping two: a block
only ever reads the names, never the values. */
:root {
--font-ui: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
--bg: #ffffff;
--board: #ffffff;
--card: #f7f7f6;
--surface: #f7f7f6;
--surface-2: #f1f1f0;
--surface-3: #ecebe7;
--ink: #17181a;
--ink-rgb: 23, 24, 26;
--ink-2: #3c3b37;
--ink-3: #5c5b56;
--ink-4: #6f6e68;
--ink-5: #85847e;
--on-ink: #ffffff;
--on-ink-rgb: 255, 255, 255;
--slab: #17181a;
--on-slab: #ffffff;
--slab-dark: #0e0f11;
--fill-slab: #ffffff;
--fill-on: #17181a;
--fill-on-rgb: 23, 24, 26;
--pane: var(--fill-slab);
--pane-edge: rgba(23, 24, 26, 0.08);
--pane-thumb: rgba(23, 24, 26, 0.07);
--inlay: rgba(255, 255, 255, 0.55);
--inlay-hi: rgba(23, 24, 26, 0.09);
--elev-rgb: 255, 255, 255;
--glass-rgb: 255, 255, 255;
--shadow-rgb: 23, 24, 26;
--wash: 0.06;
--pick: #0d99ff;
--signal: #2231dd;
--focus: #2231dd;
--ok: #15803d;
--ember: #b8431c;
color-scheme: light;
}
[data-theme="dark"] {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
}
/* Otp.css */
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── the goo's defs hold nothing you can see ────────────────
`useGoo` renders an <svg> carrying a <defs> and nothing
else, and an <svg> with no dimensions is a replaced element:
the browser gives it the default 300x150 and puts it in the
flow. Every block that mounts one has been carrying an
invisible 300x150 box ever since — harmless in the fixed-size
relative stages that host most of them, and not harmless in
a flex column, where it over-subscribed the container and
shrank the palette's swatch row from 132 to 64.
Nothing inside a <defs> is rendered, so taking the element
out of flow entirely costs nothing and is what it always
wanted. */
.liq-defs {
position: absolute;
width: 0;
height: 0;
overflow: hidden;}
/* nothing inside a <defs> renders, and an <svg> with no
dimensions is otherwise a 300x150 box in the flow — the same
fault .liq-defs had */
.cow-defs {
position: absolute;
width: 0;
height: 0;}
/* ══ One-time code ═════════════════════════════════════════
lab/Otp.tsx. Everything that moves is written inline; what
is here is the material. Positioned at the root so the
canvas's grab halo does not paint over the field — see the
note on .gen. */
.otp {
position: relative;
font-family: var(--font-ui);
display: grid;
place-items: center;}
.otp-row {
position: relative;}
.otp-goo {
position: absolute;
inset: 0;}
/* one colour under the filter, or the threshold smears two */
.otp-cell {
position: absolute;
left: 0;
top: 0;
height: 100%;
background: var(--fill-slab, var(--card));}
.otp-slot {
position: absolute;
left: 0;
top: 0;
height: 100%;
display: grid;
place-items: center;
pointer-events: none;}
.otp-digit {
font-size: 20px;
font-weight: 500;
line-height: 1;
letter-spacing: -0.02em;
font-variant-numeric: tabular-nums;
color: var(--fill-on, var(--ink));
animation: otp-in 300ms cubic-bezier(0.22, 1, 0.36, 1) both;
transition: color 160ms ease;}
.otp[data-phase="no"] .otp-digit { color: #e5484d; }
.otp-caret {
position: absolute;
left: 0;
top: 50%;
width: 2px;
height: 18px;
margin-top: -9px;
border-radius: 2px;
background: var(--fill-on, var(--ink));
opacity: 0;
pointer-events: none;
transition: opacity 160ms ease;}
.otp-caret[data-on="true"] {
opacity: 1;
animation: otp-breathe 1.1s ease-in-out infinite alternate;}
.otp-ok {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
font-size: 14px;
font-weight: 400;
color: var(--fill-on, var(--ink));
pointer-events: none;
letter-spacing: -0.01em;}
/* the field: over the whole row, there and invisible. 16px so
iOS does not zoom the page when it takes focus. */
.otp-field {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
opacity: 0;
border: 0;
padding: 0;
font-size: 16px;
caret-color: transparent;
cursor: text;
letter-spacing: -0.01em;}
.otp[data-phase="ok"] .otp-field { cursor: pointer; }
@media (prefers-reduced-motion: reduce) {
.otp-digit { animation: none; }
}
@media (prefers-reduced-motion: reduce) {
.otp-caret[data-on="true"] { animation: none; }
}
@keyframes otp-in {
from { transform: translateY(45%) scale(0.86); opacity: 0; filter: blur(3px); }
to { transform: none; opacity: 1; filter: none; }}
@keyframes otp-breathe {
from { opacity: 1; }
to { opacity: 0.25; }}
// bencho source (MIT). npm i @tabler/icons-react motion react · Tailwind CSS v4
// ── blocks/one-time-code/Otp.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/one-time-code/Otp.tsx)
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
import { useEffect, useId, useRef, useState } from "react";
import { IconCheck as Check } from "@tabler/icons-react";
/* ══ One-time code ════════════════════════════════════════
Six small cells and a caret. Digits rise into their cells;
a right code draws the cells together until they fuse into
one capsule that says so, and a wrong one sends a shiver
down the row and drains the digits out.
── SIX CELLS, ONE FIELD ────────────────────────────────
The same call the sign-in sheet makes, for the same reasons:
six real inputs break paste, autofill from the notification,
backspace and screen readers. So there is one invisible
input over the row and the cells are drawn underneath it.
── THE MERGE IS THE GOO'S ──────────────────────────────
The cells sit under a blur-and-threshold filter, far enough
apart that it never bridges them. Verifying slides them to
the middle while a capsule grows out of the same point: as
they close, the filter joins them, and what is left is one
shape. Nobody draws the in-between — it is the filter
deciding when two things are close enough to be one.
── THE ANSWER IS A KNOB ────────────────────────────────
A code nobody on the wall can know is not a demonstration.
Accept and Reject are the two things the component does
with a full row, so the panel picks which one you see. */
/* ── inlined from lab/motionkit ──────────────────────── */
/* ══ liquid ═══════════════════════════════════════════════
Shared parts for the Framer Motion layer: one spring, one
goo filter, one velocity→skew binding.
── why the filter is a hook ────────────────────────────
The filter is embedded in each component's own return, but
its id CANNOT be a literal. Every block here renders twice
at once — once in the wall card, once in the detail overlay
— and duplicate SVG ids do not scope, they collide: the
second instance silently steals the first one's filter.
useId() gives each mount its own name.
── what the goo can and cannot do ──────────────────────
This is feGaussianBlur + feColorMatrix, not a shader. The
matrix multiplies alpha by `cut` and subtracts half of it,
so alpha below 0.5 lands on zero and everything above 0.536
is fully opaque. That hard edge is what fuses nearby shapes
into one blob — and it is also why this must never touch
text: glyph antialiasing lives entirely below 0.5, so type
under this filter loses its edges and then itself. */
function useGoo(blur = 7, cut = 28) {
/* useId yields ":r0:" — legal in an id attribute but not in
a url(#…) reference, so strip the colons. */
const id = `goo-${useId().replace(/:/g, "")}`;
const goo = (
<svg className="liq-defs" aria-hidden="true" focusable="false">
<defs>
<filter
id={id}
x="-50%"
y="-50%"
width="200%"
height="200%"
colorInterpolationFilters="sRGB"
>
<feGaussianBlur in="SourceGraphic" stdDeviation={blur} result="smear" />
<feColorMatrix
in="smear"
type="matrix"
values={`1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 ${cut} ${-(cut / 2)}`}
/>
</filter>
</defs>
</svg>
);
return { id, url: `url(#${id})`, goo };
}
/* ── inlined from lab/spring ──────────────────────── */
/* ── one spring, for everything that settles ───────────────
The maths was already on this bench twice, copied by hand:
Humidity's wheel and Brightness's column both accumulate
velocity toward a target, damp it, and snap when both the
delta and the velocity fall under 0.02. Two copies is a
coincidence; five would be a policy, so it comes out here
before the elastic blocks are written against it.
The two shipped copies are deliberately NOT refactored onto
this. They work, they are tuned, and rewriting the innards
of two live components to prove a point about duplication
is how a good afternoon becomes a bad one. This is the one
new code uses.
Frames, not milliseconds. `dt` is expressed in sixtieths of
a second and the damping is RAISED to it rather than
multiplied by it, so a dropped frame decays the same amount
of energy as the two frames it replaced. Multiplying is the
version that makes a spring behave differently on a busy
page, which is the hardest kind of bug to see.
The loop parks itself the moment the value has settled.
CLAUDE.md is not complimentary about the one permanent
requestAnimationFrame already on this bench and there is no
case for five more. */
/* Read once, the way the wheel and the pill nav do. A
preference, not a live input. */
const stillness = () =>
typeof window !== "undefined" &&
!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/* how long a cell takes to swell and settle when a digit lands */
const POP_MS = 260;
const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));
const mix = (a: number, b: number, t: number) => a + (b - a) * t;
const smooth = (a: number, b: number, v: number) => {
const u = clamp((v - a) / (b - a), 0, 1);
return u * u * (3 - 2 * u);
};
/* a cell, and the air between two */
const W = 36;
const H = 44;
const G = 7;
/* the capsule a right code becomes */
const CAP = 128;
/* ── the merge is a SPRING, not a tween ─────────────────
It was a 560ms ease-in-out, which arrived and stopped. A
spring a little under critical lets the capsule run past its
size and come back — stretching long and thin on the way out
and settling round — which is what makes the fuse read as
liquid rather than as boxes sliding. Per frame at 60Hz, from
a stiffness and a damping ratio, as spring.ts does. */
const MERGE = (() => {
const k = 0.075;
const zeta = 0.42;
return { k, d: 1 - 2 * zeta * Math.sqrt(k) };
})();
const SHAKE_MS = 620;
type Phase = "type" | "check" | "ok" | "no";
export function Otp({
/* how many digits, 4 or 6 */
length = 4,
/* what a full row gets back */
answer = "Accept",
/* the cells' corner, px; the capsule wears the same one */
corner = 12,
}: {
length?: number;
answer?: string;
corner?: number;
} = {}) {
const n = length === 4 ? 4 : 6;
const r = clamp(corner, 0, H / 2);
const rowW = n * W + (n - 1) * G;
const still = stillness();
const [code, setCode] = useState("");
const [phase, setPhase] = useState<Phase>("type");
const [focus, setFocus] = useState(false);
const input = useRef<HTMLInputElement | null>(null);
/* moving parts, read by the loop */
const caret = useRef({ x: W / 2, v: 0 });
/* when each cell last took a digit — for the little swell */
const popAt = useRef<number[]>([]);
const merge = useRef({ m: 0, v: 0, to: 0 });
const shook = useRef(0);
const timers = useRef<number[]>([]);
const raf = useRef(0);
const [, setTick] = useState(0);
const live = useRef({ code, n });
live.current = { code, n };
const later = (fn: () => void, ms: number) => {
timers.current.push(window.setTimeout(fn, ms));
};
/* ── the one loop ────────────────────────────────────────
Runs while something moves and stops itself after, so a
row nobody is typing into costs nothing. */
const wake = () => {
if (raf.current) return;
let prev = 0;
const tick = (t: number) => {
const dt = prev ? clamp((t - prev) / 16.67, 0, 2.5) : 1;
prev = t;
let busy = false;
const { code: c, n: count } = live.current;
/* the caret, on a spring with a little give */
const target = Math.min(c.length, count - 1) * (W + G) + W / 2;
const k = caret.current;
if (still) { k.x = target; k.v = 0; }
else {
k.v += (target - k.x) * 0.2 * dt;
k.v *= Math.pow(0.62, dt);
k.x += k.v * dt;
if (Math.abs(target - k.x) < 0.05 && Math.abs(k.v) < 0.05) { k.x = target; k.v = 0; }
else busy = true;
}
/* the merge, sprung */
const mg = merge.current;
if (mg.m !== mg.to || mg.v !== 0) {
if (still) { mg.m = mg.to; mg.v = 0; }
else {
mg.v += (mg.to - mg.m) * MERGE.k * dt;
mg.v *= Math.pow(MERGE.d, dt);
mg.m += mg.v * dt;
if (Math.abs(mg.to - mg.m) < 0.0008 && Math.abs(mg.v) < 0.0008) { mg.m = mg.to; mg.v = 0; }
else busy = true;
}
}
if (t - shook.current < SHAKE_MS + 200) busy = true;
setTick((x) => x + 1);
/* a cell still swelling from a digit keeps the loop alive */
if (popAt.current.some((at) => t - at < POP_MS)) busy = true;
raf.current = busy ? requestAnimationFrame(tick) : 0;
};
raf.current = requestAnimationFrame(tick);
};
useEffect(() => () => {
cancelAnimationFrame(raf.current);
raf.current = 0;
timers.current.forEach(window.clearTimeout);
}, []);
useEffect(() => { wake(); }, [code, n, phase]);
const fuse = (to: 0 | 1) => {
merge.current = { ...merge.current, to };
wake();
};
/* a row that has been answered, and a length knob moving
under it, both start over */
useEffect(() => {
setCode("");
setPhase("type");
merge.current = { m: 0, v: 0, to: 0 };
}, [n]);
const onChange = (raw: string) => {
if (phase !== "type") return;
const next = raw.replace(/\D/g, "").slice(0, n);
/* each new digit swells its cell — a paste runs along the row */
if (!still && next.length > code.length) {
const t0 = performance.now();
for (let i = code.length; i < next.length; i++) popAt.current[i] = t0 + (i - code.length) * 45;
wake();
}
setCode(next);
if (next.length < n) return;
/* full: a beat of checking, then the answer */
setPhase("check");
later(() => {
if (answer !== "Reject") {
setPhase("ok");
fuse(1);
input.current?.blur();
} else {
setPhase("no");
shook.current = performance.now();
wake();
later(() => {
setCode("");
setPhase("type");
}, SHAKE_MS + n * 45 + 160);
}
}, still ? 0 : 420);
};
/* pressing the capsule splits it back into empty cells */
const reopen = () => {
if (phase !== "ok") return;
setCode("");
setPhase("type");
fuse(0);
input.current?.focus();
};
/* ── where everything is this frame ──────────────────────── */
const now = performance.now();
/* the raw spring runs past 0 and 1; the cells' travel is
clamped to it, and only the capsule is allowed to take the
overshoot, as a stretch */
const raw = merge.current.m;
const m = clamp(raw, 0, 1);
const em = m;
const home = (i: number) => i * (W + G);
const mid = (rowW - W) / 2;
const since = now - shook.current;
const shaking = phase === "no" && since < SHAKE_MS && !still;
const shake = (i: number) =>
shaking ? 5 * Math.exp(-since / 190) * Math.sin((since / 1000) * Math.PI * 2 * 10 + i * 0.55) : 0;
const cellX = (i: number) => mix(home(i), mid, em) + shake(i);
/* ── a digit arriving ─────────────────────────────────────
The cell that takes it swells a touch and settles: up and
back on one half-sine, four per cent at the top. Small on
purpose — it is an acknowledgement, not an event. */
const pop = (i: number) => {
const at = popAt.current[i];
if (at === undefined) return 1;
const u = (now - at) / POP_MS;
return u > 0 && u < 1 ? 1 + 0.04 * Math.sin(Math.PI * u) : 1;
};
/* checking: a soft wave of breath through the cells */
const breath = (i: number) => {
if (phase !== "check" || still) return pop(i);
const u = ((now % 900) / 900) * (n + 2) - i;
return 1 - 0.07 * (u > 0 && u < 2 ? Math.sin((u / 2) * Math.PI) : 0);
};
const over = raw - 1;
/* long and thin past its size, round again as it settles:
width and height trade, so it reads as one soft thing */
const capW = CAP * smooth(0.3, 1, m) * (1 + Math.max(-0.12, over) * 0.9);
const capSy = 1 - Math.max(-0.12, over) * 0.55;
/* cells round off into the capsule's pill as they close in,
so the two shapes agree by the time the goo joins them */
const cellR = mix(r, H / 2, smooth(0.15, 0.7, m));
const typing = phase === "type" && focus;
const { url, goo } = useGoo(3, 24);
return (
<div className="otp" data-phase={phase}>
<div className="otp-row" style={{ width: rowW, height: H }}>
{/* the cells and the capsule: one colour, under the filter */}
<div className="otp-goo" aria-hidden="true" style={{ filter: still ? undefined : url }}>
{Array.from({ length: n }, (_, i) => (
<span
key={i}
className="otp-cell"
style={{
width: W,
borderRadius: cellR,
transform: `translateX(${cellX(i).toFixed(2)}px) scale(${breath(i).toFixed(3)})`,
}}
/>
))}
{capW > 0.5 && (
<span
className="otp-cell"
/* always a full pill — the capsule is a result, not
a cell, and wears the rounded shape whatever the
Corner knob says the cells are */
style={{
width: capW,
borderRadius: H / 2,
transform: `translateX(${((rowW - capW) / 2).toFixed(2)}px) scaleY(${capSy.toFixed(3)})`,
}}
/>
)}
</div>
{/* the digits — an empty cell is just the cell */}
{Array.from({ length: n }, (_, i) => {
const d = code[i];
const x = cellX(i);
/* a wrong code drains right to left */
const out = phase === "no" && !still ? smooth(0, 1, (since - 300 - (n - 1 - i) * 45) / 220) : 0;
return (
<span
key={i}
className="otp-slot"
style={{
width: W,
transform: `translateX(${x.toFixed(2)}px)`,
opacity: 1 - smooth(0, 0.45, m),
}}
>
{d && (
<span
key={`${i}-${d}`}
className="otp-digit"
style={{ translate: `0 ${(out * 8).toFixed(2)}px`, opacity: 1 - out }}
>
{d}
</span>
)}
</span>
);
})}
{/* the caret, stretched by its own speed */}
<i
className="otp-caret"
/* not until the cells have come apart again, or it
stands in an empty slot the capsule is still on */
data-on={typing && code.length < n && m < 0.08}
style={{
transform: `translateX(${(caret.current.x - 1).toFixed(2)}px) scaleX(${(1 + Math.min(5, Math.abs(caret.current.v) * 0.9)).toFixed(3)})`,
}}
/>
{/* what the capsule says */}
<span className="otp-ok" style={{ opacity: smooth(0.72, 1, m), scale: `${mix(0.92, 1, smooth(0.72, 1, m))}` }}>
<Check size={14} strokeWidth={2} aria-hidden="true" />
Verified
</span>
<input
ref={input}
className="otp-field"
value={code}
onChange={(e) => onChange(e.target.value)}
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
onPointerDown={(e) => { if (phase === "ok") { e.preventDefault(); reopen(); } }}
inputMode="numeric"
autoComplete="one-time-code"
/* a code box is not a login: keep the password managers'
badges out of it, the way each of them asks */
data-1p-ignore
data-lpignore="true"
data-bwignore
data-form-type="other"
maxLength={n}
aria-label={phase === "ok" ? "Verified. Press to enter a new code" : `${n}-digit code`}
spellCheck={false}
/>
</div>
{goo}
</div>
);
}Controles · HTML · CSS · JS
Edita el código y ajústalo con los controles. La vista previa se actualiza mientras escribes.

Este componente se ejecuta desde un paquete compilado, así que su script es de solo lectura aquí. Edita el HTML y el CSS; el código completo está en la pestaña Código.
Edita cada componente en directo, ajústalo con controles, descarga el código completo y copia los prompts avanzados.
49 $ pago únicoPrecio provisional
Modo de prueba: no se cobra nada real.
Gratis: vista previa, botones de copiar y notas de la lección.
Una etiqueta visible, un borde tranquilo y un foco claro guían la escritura.
Búsqueda, inicio de sesión y campos de texto cortos.
Ajusta la altura, el color del borde y el brillo al enfocar.
Añade el componente "One-time code" de Bencho (github.com/cabralorenzo/bencho) (MIT) a mi aplicación React + Tailwind CSS. Archivo fuente: https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/one-time-code/Otp.tsx. Una etiqueta visible, un borde tranquilo y un foco claro guían la escritura. Úsalo para: Búsqueda, inicio de sesión y campos de texto cortos. Ajustes que se pueden cambiar: Ajusta la altura, el color del borde y el brillo al enfocar. Admite temas claro y oscuro y respeta prefers-reduced-motion. Conserva el aviso de licencia MIT.
Un prompt más largo con pasos de ajuste, accesibilidad e integración.