パフォーマンス
注意フレームレート: 平均 60 fps、p5 59.9 · ロングタスク: 0 件、合計 0 ミリ秒、最長 0 ミリ秒 · ソース gzip 11 KB · 実行時 159 KB
Escape buttonMITボタンBencho
Lorenzo Cabra によるボタンの React コンポーネント。MIT ライセンスのもと Bencho から改変せずに収録し、ライブで表示しています。
品質レポート
評価と点数は、ビルドまたはテスト時に実行した自動チェックの結果です。未実施の項目は「未テスト」と表示し、数字を仮置きすることはありません。
フレームレート: 平均 60 fps、p5 59.9 · ロングタスク: 0 件、合計 0 ミリ秒、最長 0 ミリ秒 · ソース gzip 11 KB · 実行時 159 KB
問題 0 · スクリーンリーダー: 合格
継続する動きはない
はみ出しなし
フレームレートとロングタスクは、ヘッドレスの Chromium 上でソフトウェア WebGL を使って測定しています。このサイト内のコンポーネント同士の比較にのみ用いてください。実機の数値ではありません。
該当なし。静止時に見えるアニメーションはありません。ホバーで始まるアニメーションは未テストです。
axe-core の違反はありません。

検査日 2026年11月15日 · 数値は自動スクリプトによるもので、手書きの見本ではありません。
実寸で表示しています。
コピーした内容の先頭にライセンス表記があります。使うときは残してください。
<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;
}
}
/* Escape.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.
*/
/* ── flat panes ────────────────────────────────────────────
Set data-surface="flat" on any ancestor and every glass
surface under it becomes a solid fill with a hairline. The
inner buttons already sit on rgba(var(--ink-rgb), 0.05)
with no border, which is what flat wants anyway, so they
need nothing.
The frost is switched off at the element rather than through
a token. A var() holding a url() filter cannot be validated
at parse time, so the browser would treat it as invalid at
computed-value time and drop the property outright — which
breaks the two-declaration fallback the glass depends on. */
/* ══ stroke ═════════════════════════════════════════════════
Whether a component draws a hairline round itself. OFF by
default, which is the change: every glass surface carried
one unconditionally, and a grey line round everything makes
a wall of components look like a wall of boxes rather than
a wall of things.
The line is not load-bearing. A flat pane is a fill against
a different fill and reads on its own; the ring was there
to sharpen an edge that was already there.
Placed ABOVE the glass rules on purpose. Glass draws its
own lit rim, and that rim is the material rather than a
stroke — it is what gives a pane thickness. So glass wins
the border wherever the two meet, and Stroke governs the
drawn line that flat surfaces would otherwise have. */
[data-stroke="on"] .lab::before,
[data-stroke="on"] .gcard::before,
[data-stroke="on"] .gpane::before,
[data-stroke="on"] .gnav::before,
[data-stroke="on"] .gdock::before,
/* the playful blocks. None of them is glass, so none has a
lit rim for the stroke to lose to — the hairline is the
only edge they can have, and it is the whole of what this
control does for them. */
[data-stroke="on"] .esc-btn::before,
[data-stroke="on"] .slo-track::before,
[data-stroke="on"] .sek-skin::before {
border-color: var(--pane-edge);}
/* ══ playful blocks ═════════════════════════════════════════
Escape, Slosh, Shy. The behaviour is the joke and
the material is not in on it — these use the same ink, the
same wells and the same corners as everything else on the
bench. A block that announces it is being funny is not.
Every one of them is sized here rather than by whatever
holds it: the wall measures a component and scales it, the
canvas packs a declared footprint, and both need something
to measure. Escape in particular needs a real box, because
"it can never leave its own container" is a promise about a
specific number of pixels. */
.ply {
position: relative;
box-sizing: border-box;
font-family: var(--font-ui);
color: var(--ink);}
/* The field the two buttons move inside, and it paints
nothing at all.
It was a grey well, on the reasoning that an invisible
boundary reads as the button sticking. That reasoning was
right about a SMALL boundary and wrong about the component:
a 300x160 box put the clamp about fifty pixels from home in
every direction, so the button hit the wall constantly and
the wall had to be drawn to explain itself. Draw the wall
and you have also drawn a widget sitting in a box, which is
the one thing on this bench that has a frame round it.
Bigger, and the problem goes away rather than needing to be
explained: at 360x240 the clamp is over a hundred pixels
out and the button almost never reaches it. What is left is
a button on the page with room to bolt across, which is
what it always should have been. The box still EXISTS —
it is the layout box the travel is clamped to and the fixed
centre both blocks measure home from — it simply has no
surface. */
.ply-field {
width: 360px;
height: 240px;
display: grid;
place-items: center;}
/* Escape's field at the 300 standard block width; Slosh keeps its own */
.ply-field.esc { width: 300px; }
/* ── 1 · Escape ───────────────────────────────────────────
Two durations behind one attribute. Fleeing is 130ms: long
enough that a dart across the cursor — which happens every
time you walk through the button's home position, and is
the best thing this component does — travels rather than
teleporting, and short enough that it is never a wind-up.
Coming home is 620 and soft, because that one is a relief
rather than a reaction. */
/* ── the filled surfaces ──────────────────────────────────
Escape's pill, Slosh's track and Shy's card each read
--fill-slab / --fill-on, so Fill is a real control on all
three rather than a row that moves nothing.
Every one of them keeps its own value as the var() FALLBACK
and not as a second declaration underneath, which is what
lets one line serve both cases.
And both cases do happen. `.bench-app` carries a data-fill
of its own that follows the theme, so on the wall these are
already filled — a white pill on a light bench, a near-black
one on a dark bench — and the overlay's control is then a
choice to differ from that rather than a switch from
nothing. The fallback is for a surface mounted outside
`.bench-app` altogether, which is what a component lifted
out of this project is.
--fill-on-rgb rather than --fill-on wherever the ink is not
at full strength: a fallback has to nest INSIDE the rgba()
to survive, so it is rgba(var(--fill-on-rgb, var(--ink-rgb)), .78)
and never rgba(var(--fill-on), .78). */
.esc-btn {
position: relative;
/* the box stays the size it was asked to be — it is the TYPE
that had to come back into line, not the target */
height: 44px;
padding: 0 24px;
border: 0;
border-radius: var(--esc-r, 999px);
background: var(--fill-slab, rgba(var(--ink-rgb), var(--wash)));
color: color-mix(in srgb, var(--fill-on, #17181a) 72%, var(--fill-slab, #ffffff));
font: inherit;
/* a button's size on the system: 16 medium in a 44 pill. It was
20 in a 56, set to come out at 14 back when the wall drew this
block at 0.72; the wall draws every block at 1 now, and 20 was
the largest button on it */
font-size: 16px;
font-weight: 500;
letter-spacing: -0.01em;
cursor: pointer;
/* the drift home: soft, slightly overshot, and long enough
to read as the button relaxing rather than snapping */
transition:
transform 600ms cubic-bezier(0.24, 1.34, 0.38, 1),
background 220ms ease,
color 220ms ease;}
/* the hairline, hung on a ::before like every other stroke on
the bench — transparent until Stroke says otherwise */
.esc-btn::before,
.slo-track::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
border: 1px solid transparent;
pointer-events: none;}
.esc-btn[data-fled="true"] {
transition:
transform 160ms cubic-bezier(0.22, 1, 0.36, 1),
background 220ms ease,
color 220ms ease;}
.esc-btn:hover { color: var(--fill-on, var(--ink)); }
/* given in. It stops moving, it says so, and it is now an
ordinary button — which is the entire payoff and has to
look like an invitation rather than a defeat. */
.esc-btn[data-caught="true"] { color: var(--fill-on, var(--ink)); }
/* pressed: the chosen fill INVERTED rather than a slab of its
own. --slab was here and it fought Fill — pick a dark pill
and the press turned it dark again, which is the confirming
beat saying nothing. Swapping the two tokens is the same
beat in whichever fill you asked for. */
.esc-btn[data-done="true"] {
background: var(--fill-on, var(--ink));
color: var(--fill-slab, var(--on-ink));}
.esc[data-flat] .esc-btn,
.esc[data-flat] .esc-btn[data-fled="true"] { transition: background 160ms linear, color 160ms linear; }
// bencho source (MIT). npm i motion react · Tailwind CSS v4
// ── blocks/escape/Escape.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/escape/Escape.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, useLayoutEffect, useRef, useState } from "react";
import type { RefObject } from "react";
/* ══ playful blocks ═══════════════════════════════════════
Two components whose behaviour is the joke. The material
stays as quiet as everything else on this bench — no
confetti, no exclamation marks, no sound. If the decoration
is doing the work then the interaction is not.
THE JOKE HAS TO RESOLVE. A button that never lets itself be
clicked is friction with a smirk on it. A button that
dodges four times and then gives up is a small story with
an ending, and the ending is the reason it is worth
shipping rather than a garnish on top of one.
Which makes one rule absolute here: none of these may trap
anybody. Every one of them completes, every one of them
completes within a few seconds, and every one of them
completes from the keyboard on the first try — the tease is
a pointer phenomenon and a person who is not using a
pointer is not the audience for it. */
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
/* Read once, like the wheel and the pill nav do. This is a
preference, not a live input — a person who changes it
mid-session gets it on the next render of the page, which
is soon enough and costs nothing to be wrong about. */
const still = () =>
typeof window !== "undefined" &&
!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
/* ── proximity ─────────────────────────────────────────────
One caller now that Shy is gone — Escape pushes along the
vector. Kept as a hook rather than folded back into the
component because the awkward part is the frame of
reference, not the maths, and that is the part worth having
written down once.
The vector is from the element's CENTRE to the cursor, in
the element's own pixels — which is the awkward part. The
canvas draws boards at a zoom, so a rect comes back in
screen pixels while a transform the component writes is
applied in its own. Divide one by the other and a 120px
radius is 120px of component at any zoom. It is the same k
the deck and the create menu divide their drags by.
Listening on the nearest scrolling ancestor rather than on
window is not tidiness. It is what makes SCROLL a source of
proximity: the cursor can sit perfectly still while the
page moves the element out from under it, and no
pointermove is fired for that. The last pointer position is
kept so a scroll can re-ask the question with it. */
type Near = {
/* centre → cursor, in the element's own px */
dx: number;
dy: number;
distance: number;
inside: boolean;
};
const AWAY: Near = { dx: 0, dy: 0, distance: Infinity, inside: false };
function scrollerOf(el: Element): HTMLElement | Document {
for (let n = el.parentElement; n; n = n.parentElement) {
const o = getComputedStyle(n);
if (/auto|scroll/.test(o.overflowY) || /auto|scroll/.test(o.overflowX)) return n;
}
return document;
}
/* Not exported. It is used twice, both times in this file,
and exporting a hook beside components is what breaks Fast
Refresh for the whole module. The day a third block wants
it, it moves to a file of its own — which is precisely what
the lint rule is asking for. */
function useProximity<T extends HTMLElement>(
ref: RefObject<T | null>,
{ radius }: { radius: number },
): Near {
const [near, setNear] = useState<Near>(AWAY);
/* the answer, and the frame that will publish it. A
pointermove fires per pixel of travel and this drives a
transform, so it is read eagerly and rendered once a
frame — the wall can carry several of these. */
const at = useRef<Near>(AWAY);
const frame = useRef(0);
const pt = useRef<{ x: number; y: number } | null>(null);
useEffect(() => {
const el = ref.current;
if (!el) return;
const host = scrollerOf(el);
const publish = () => {
frame.current = 0;
setNear(at.current);
};
const push = (v: Near) => {
at.current = v;
if (!frame.current) frame.current = requestAnimationFrame(publish);
};
const measure = () => {
const p = pt.current;
if (!p) return;
const box = el.getBoundingClientRect();
const k = box.width / (el.offsetWidth || box.width) || 1;
const dx = (p.x - (box.left + box.width / 2)) / k;
const dy = (p.y - (box.top + box.height / 2)) / k;
const distance = Math.hypot(dx, dy);
const inside = distance <= radius;
/* out, and it was already out. The overwhelming majority
of pointermoves on a page are this, and they must cost
a rect and nothing else. */
if (!inside && !at.current.inside) return;
push({ dx, dy, distance, inside });
};
const read = (e: Event) => {
const p = e as PointerEvent;
pt.current = { x: p.clientX, y: p.clientY };
measure();
};
const gone = () => {
pt.current = null;
if (at.current.inside) push(AWAY);
};
host.addEventListener("pointermove", read, { passive: true });
host.addEventListener("scroll", measure, { passive: true });
/* leaving the scroller is leaving; a pointer that has gone
to another pane is not near anything in this one */
host.addEventListener("pointerleave", gone);
return () => {
host.removeEventListener("pointermove", read);
host.removeEventListener("scroll", measure);
host.removeEventListener("pointerleave", gone);
cancelAnimationFrame(frame.current);
frame.current = 0;
};
}, [ref, radius]);
return near;
}
/* ── the room a block has to move in ───────────────────────
Escape translates a button inside a field and may never
push it out of one. The bound is measured rather than
assumed: the field is fixed by the stylesheet but the
button is as wide as its label, and its label changes.
offsetWidth, never a rect — the canvas zoom is exactly the
thing this must not be measured in. */
function useRoom(
field: RefObject<HTMLElement | null>,
moving: RefObject<HTMLElement | null>,
inset = 12,
) {
const [room, setRoom] = useState({ x: 0, y: 0 });
useLayoutEffect(() => {
const f = field.current;
const m = moving.current;
if (!f || !m) return;
const read = () =>
setRoom({
x: Math.max(0, (f.clientWidth - m.offsetWidth) / 2 - inset),
y: Math.max(0, (f.clientHeight - m.offsetHeight) / 2 - inset),
});
read();
const ro = new ResizeObserver(read);
ro.observe(f);
ro.observe(m);
return () => ro.disconnect();
}, [field, moving, inset]);
return room;
}
/* ══ 1 · Escape ═══════════════════════════════════════════
A button that slides away from the cursor, and then stops.
THE NOTE THIS ONE HAS TO CARRY: near-miss targeting is one
hop from a genuine dark pattern. The same mechanism aimed
the other way is a close button that drifts out from under
a finger, a decline that is a little harder to hit than an
accept, an unsubscribe that needs a second go. What keeps
this on the right side of the line is not taste, it is the
count: it gives in on its own, quickly, every time, and
activating it from the keyboard never dodges at all. Take
the count out and this is not a joke any more, it is the
pattern it is imitating. */
/* the button's corner. 28 is half of its 56px height, so the
default IS the pill it has always been and the slider only
has somewhere to go downwards. */
const ESC_CORNER = 28;
export function Escape({
/* how hard it pushes away, 0..100 */
skittishness = 55,
/* dodges before it gives in */
patience = 4,
/* the detection field, px */
radius = 120,
/* the corner it is cut with */
corner = ESC_CORNER,
}: {
skittishness?: number;
patience?: number;
radius?: number;
corner?: number;
} = {}) {
const field = useRef<HTMLDivElement | null>(null);
const btn = useRef<HTMLButtonElement | null>(null);
/* ── measured from the FIELD, not from the button ───────
The button is centred in the field and the field never
moves, so the field's centre is the button's HOME — and
that is the only frame this can honestly be computed in.
Measuring off the button's own rect is the obvious way to
write it and it is a feedback loop: the displacement is a
function of a position the displacement just changed. It
converges — flee falls off with distance, so the loop is
a contraction — but it converges by RINGING, and it rings
at whatever rate pointermoves arrive. Ten events at one
fixed cursor point produced 21, 35, 26, 32, 28, 30, 29,
30, 29, 29px: a ±6px shiver on a 40px pill, seeded fresh
by every event, which on a moving cursor never stops.
From home it is a pure function of where the cursor is.
One answer per position, no ring, and it can be reasoned
about — including the one case that matters, below. */
const near = useProximity(field, { radius });
const room = useRoom(field, btn);
const reduced = still();
/* The direction is undefined when the cursor is exactly on
home, and it INVERTS as the cursor crosses it — which is
the good behaviour, not a bug: the button darts around
you to the other side rather than being walked into a
corner. Held so the undefined frame keeps the last
answer, and the flip travels (see the CSS) rather than
teleporting. */
const dir = useRef({ x: 1, y: 0 });
const [dodges, setDodges] = useState(0);
/* the beat after it is pressed, before it forgets the whole
thing and starts again for the next person */
const [gave, setGave] = useState(false);
const off = useRef(0);
/* One dodge per approach. Without this a cursor resting on
the boundary counts one a frame and the payoff arrives
before the joke does. It re-arms only on the way out of
the full radius, so a single sweep through is a single
dodge however fast it was.
The count is not shown any more. There was a row of dots
under the button reporting it, on the argument that
giving in would otherwise read as breaking — and that
argument was wrong in the way most legibility arguments
are wrong: it spent the surprise to prevent a confusion
nobody actually had. "Fine." arriving unannounced after
three or four dodges IS the joke; a progress bar toward
it is a spoiler with a UI. */
const armed = useRef(true);
const caught = dodges >= patience;
useEffect(() => () => window.clearTimeout(off.current), []);
useEffect(() => {
if (caught) return;
if (near.distance < radius * 0.55) {
if (armed.current) {
armed.current = false;
setDodges((d) => d + 1);
}
} else if (near.distance > radius) {
armed.current = true;
}
}, [near.distance, radius, caught]);
/* Displacement is read straight off the distance rather
than sprung toward it: a spring would give it a wind-up,
and the whole character of this is that it is already
gone by the time you arrive.
Squared, so it barely stirs at the edge of the field and
bolts over the last third. Linear made it drift away from
a cursor two rooms distant, which reads as a bug. */
const flee = caught || !near.inside || reduced ? 0 : (1 - near.distance / radius) ** 2;
/* Up to 120px of travel, from 90. The field used to leave
about fifty pixels of room in the short axis, so the top
of this range was a number the clamp ate — raising it
without giving the block somewhere to go would have been
a knob that stops working halfway along. */
const reach = 14 + (skittishness / 100) * 106;
if (near.distance > 6 && near.distance < Infinity) {
dir.current = { x: -near.dx / near.distance, y: -near.dy / near.distance };
}
const ox = clamp(dir.current.x * flee * reach, -room.x, room.x);
const oy = clamp(dir.current.y * flee * reach, -room.y, room.y);
/* Any activation resolves it, at any count. A person who
actually catches it deserves the ending, and a person on
a keyboard — who never saw it move — must not be handed a
button that ignores them four times first. */
const take = () => {
setGave(true);
window.clearTimeout(off.current);
off.current = window.setTimeout(() => {
setGave(false);
setDodges(0);
armed.current = true;
}, 760);
};
return (
/* Reduced motion takes the travel and leaves the joke:
the count still runs, it still gives in on the same
dodge, and the button simply never leaves the middle. */
<div
className="ply ply-field esc"
ref={field}
data-flat={reduced || undefined}
style={{ "--esc-r": `${clamp(corner, 0, ESC_CORNER)}px` } as React.CSSProperties}
>
<button
ref={btn}
className="esc-btn"
data-caught={caught || gave}
data-done={gave}
/* two durations, one attribute. Fleeing is short —
long enough that a dart across the cursor travels
instead of teleporting, short enough that it is
never a wind-up. Coming home is the soft one. */
data-fled={near.inside && !caught}
style={{ transform: `translate(${ox.toFixed(2)}px, ${oy.toFixed(2)}px)` }}
onClick={take}
>
{caught || gave ? "Fine." : "Touch me"}
</button>
</div>
);
}コントロール · HTML · CSS · JS
コードを編集し、コントロールで調整できます。入力に合わせてプレビューが更新されます。

すべてのコンポーネントをその場で編集し、コントロールで調整し、全ソースをダウンロードし、上級プロンプトをコピーできます。
買い切り $49仮の価格
テストモード:実際の支払いは発生しません。
無料:プレビュー、コピーボタン、レッスンの解説。
はっきりした形、強い一色、短い押し込みの反応で、手触りが生まれます。
メインの操作、行動の呼びかけ、ツールバー。
角の丸み、余白、ホバー時の変化の長さを変えます。
Bencho (github.com/cabralorenzo/bencho)(MIT)の「Escape button」コンポーネントを私の React + Tailwind CSS アプリに追加してください。ソースファイル:https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/escape/Escape.tsx。はっきりした形、強い一色、短い押し込みの反応で、手触りが生まれます。 用途:メインの操作、行動の呼びかけ、ツールバー。 調整する設定:角の丸み、余白、ホバー時の変化の長さを変えます。 ライトとダークのテーマに対応し、prefers-reduced-motion を尊重してください。MIT ライセンス表記は残してください。
調整、アクセシビリティ、組み込み手順まで含む長めのプロンプトです。