Leistung
HinweisBildrate: im Mittel 60 fps, p5 59.9 · Lange Aufgaben: 0 Aufgaben, insgesamt 0 ms, längste 0 ms · Quelltext gzip 9.9 KB · Zur Laufzeit 163 KB
Magnifying dockMITButtonBencho
Button-React-Komponente von Lorenzo Cabra. Unverändert aus Bencho unter der MIT-Lizenz übernommen und hier live gezeigt.
Qualitaetsbericht
Note und Punktzahl stammen aus automatischen Prüfungen beim Build oder Test. Wurde eine Prüfung nicht ausgeführt, steht dort Nicht geprüft — Zahlen werden nie erfunden.
Bildrate: im Mittel 60 fps, p5 59.9 · Lange Aufgaben: 0 Aufgaben, insgesamt 0 ms, längste 0 ms · Quelltext gzip 9.9 KB · Zur Laufzeit 163 KB
Probleme 0 · Screenreader: Hinweis
Keine dauerhafte Bewegung
Kein Ueberlauf
Bildrate und lange Aufgaben wurden in headless Chromium mit Software-WebGL gemessen. Sie eignen sich nur zum Vergleich zwischen Komponenten auf dieser Website und stehen nicht für echte Geräte.
Nicht zutreffend: in Ruhe keine sichtbare Animation. Animationen, die beim Zeigen ausgelöst werden, wurden nicht geprüft.
Keine axe-core-Verstöße.

Geprueft am 15. Nov. 2026 · Die Zahlen stammen aus einem automatischen Skript, nicht aus handgeschriebenen Beispielen.
In Originalgröße dargestellt.
Die Kopie beginnt mit dem Lizenzhinweis. Behalte ihn, wenn du den Code nutzt.
<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;
}
}
/* GlassDock.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.
*/
/* ── glass navigation ──────────────────────────────────────
Same recipe as .gcard: 60% white, 2px frost, refraction,
lit inner edge. Shapes differ, the material does not. */
/* The bare pane. Same recipe as .gnav and .gdock, with no
layout of its own — for components that are just a surface
and want to arrange themselves. A card with a title in one
corner and a chip in the other is a house style, not a
requirement, and most things do not need either. */
.gpane, .gnav, .gdock {
position: relative;
background: var(--pane);
-webkit-backdrop-filter:
blur(var(--g-blur, 2px)) saturate(var(--g-sat, 150%)) brightness(var(--g-bright, 100%));
backdrop-filter:
blur(var(--g-blur, 2px)) saturate(var(--g-sat, 150%)) brightness(var(--g-bright, 100%));
isolation: isolate;
color: var(--ink);}
.gpane::before, .gnav::before, .gdock::before {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
/* transparent unless Stroke says otherwise — see the
stroke block below */
border: 1px solid transparent;
pointer-events: none;
z-index: 3;}
/* dock */
.gdock {
display: inline-flex;
align-items: flex-end;
gap: 12px;
padding: 12px 16px;
border-radius: 28px;
/* sideways is the dock's, up and down stays the page's — a
finger passing over this on the way down the wall is
scrolling, not picking. See .tick-row. */
touch-action: pan-y;}
/* no tile behind the icon: scaling a translucent rectangle over
glass is what made this look cheap. The glyph scales instead,
and SVG scales cleanly at any size. */
.gdock-item {
position: relative;
width: 44px; height: 44px;
border: 0;
background: none;
color: var(--ink);
opacity: 0.42;
display: grid; place-items: center;
cursor: pointer;
transition: opacity 220ms ease;}
/* the magnification lives here, so the dot and the label keep
their own size and their own distance from the bar */
.gdock-glyph {
display: grid; place-items: center;
transform-origin: center bottom;
transition: transform 420ms cubic-bezier(0.24, 1.34, 0.38, 1);}
.gdock-item[data-near="1"] { opacity: 0.66; }
.gdock-item[data-near="0"] { opacity: 1; }
.gdock-item[data-active="true"] { opacity: 1; }
.gdock-item:focus-visible { outline: 1.5px solid var(--ink); outline-offset: 3px; border-radius: 10px; }
/* the running dot, the only persistent mark in the dock */
.gdock-dot {
position: absolute;
/* inside the item, not slung underneath it. The glyph is
20px in a 44px box, so anything hung off the bottom edge
lands 17px from the mark it belongs to. */
left: 50%; bottom: 3px;
width: 3px; height: 3px;
margin-left: -1.5px;
border-radius: 50%;
background: var(--ink);
opacity: 0;
transform: scale(0.4);
transition: opacity 220ms ease, transform 420ms cubic-bezier(0.24, 1.34, 0.38, 1);}
.gdock-dot[data-on="true"] { opacity: 0.55; transform: scale(1); }
/* ONE tip for the whole dock (after transitions.dev's avatar
tooltip): a dark pill above the bar that slides to the icon under
the pointer and grows or shrinks to the word, both on the same
160ms curve, and fades in 120ms. The word is centred in a box
whose width animates, and the box clips it, so a longer word is
uncovered rather than squeezed. */
.gdock-tip {
position: absolute;
left: 0;
bottom: calc(100% + 8px);
height: 32px;
display: inline-flex;
align-items: center;
justify-content: center;
overflow: hidden;
border-radius: 999px;
background: var(--fill-on, var(--ink));
color: var(--fill-slab, var(--on-ink));
font-family: var(--font-ui);
font-size: 12px;
font-weight: 400;
line-height: 32px;
white-space: nowrap;
opacity: 0;
pointer-events: none;
z-index: 2;
transition:
transform 160ms cubic-bezier(0.22, 1, 0.36, 1),
width 160ms cubic-bezier(0.22, 1, 0.36, 1),
opacity 160ms cubic-bezier(0.22, 1, 0.36, 1);
letter-spacing: 0em;}
.gdock-tip > span { flex: none; }
.gdock-tip:not([data-ready]) { transition: opacity 160ms cubic-bezier(0.22, 1, 0.36, 1); }
.gdock-tip[data-on="true"] { opacity: 1; }
/* ── 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);}
/* ── the rim ─────────────────────────────────────────────────
Every glass surface already drew a 1px ring in one flat
colour. A flat rim is the single clearest tell that a thing
is a rectangle with a border rather than a pane with
thickness: real edges are lit unevenly, and evenly lit ones
read as ink.
So the ring becomes a gradient — bright at the corner
facing the light, almost nothing along the sides that run
edge-on to it, and a second weaker catch at the far corner
where the light has come through the pane and out again.
Painting a gradient in a border needs the border box filled
and the padding box punched out of it, which is what the
two masks do: one covers the whole element, one covers only
the inside, and compositing them apart leaves the rim. It
is the only way to get a gradient into a border without a
second element to draw it on.
Only under glass. Flat keeps its honest hairline, which is
what a solid pane should have. */
[data-surface="glass"] .lab::before,
[data-surface="glass"] .gcard::before,
[data-surface="glass"] .cmd::before,
[data-surface="glass"] .gpane::before,
[data-surface="glass"] .gnav::before,
[data-surface="glass"] .gdock::before {
border-color: transparent;
background:
linear-gradient(
142deg,
rgba(255, 255, 255, var(--g-edge-hi, 0)) 0%,
rgba(255, 255, 255, var(--g-edge-lo, 0)) 26%,
rgba(255, 255, 255, var(--g-edge-lo, 0)) 62%,
rgba(255, 255, 255, var(--g-edge-far, 0)) 100%
) border-box;
-webkit-mask:
linear-gradient(#000 0 0) padding-box,
linear-gradient(#000 0 0);
-webkit-mask-composite: xor;
mask:
linear-gradient(#000 0 0) padding-box,
linear-gradient(#000 0 0);
mask-composite: exclude;}
/* ── thickness ───────────────────────────────────────────────
Three marks, and between them they are the difference
between a pane and a wash.
The lit line along the top is where light enters the edge of
a real sheet. The ring is the sheet's own thickness seen
from straight on. The shadow underneath says the pane is
ABOVE the page rather than painted onto it — which is the
one thing a backdrop-filter alone can never say, because a
filter has no depth.
All three ride on --glass and are gone at zero, where the
fallbacks take over and the surface is flat. */
[data-surface="glass"] .lab,
[data-surface="glass"] .gcard,
[data-surface="glass"] .cmd,
[data-surface="glass"] .gpane,
[data-surface="glass"] .gnav,
[data-surface="glass"] .gdock {
box-shadow: var(--g-shadow,
/* the top face, catching light through the thickness of
the pane — inside the rim, not on it */
inset 0 1px 0 rgba(255, 255, 255, var(--g-spec, 0)),
/* And what it casts on the page below — wide and soft
rather than tight and close. It is a different claim
about how far the pane floats, and the softer one is
what reads as a sheet resting above the page instead of
a card stuck to it. */
0 10px 40px rgba(var(--shadow-rgb), var(--g-lift, 0)));}
[data-surface="flat"] .lab,
[data-surface="flat"] .gcard,
[data-surface="flat"] .cmd,
[data-surface="flat"] .gnav,
[data-surface="flat"] .gdock {
-webkit-backdrop-filter: none;
backdrop-filter: none;}
/* ── a flat rim, for comparison ──────────────────────────────
Reverts the graded rim to one colour all the way round —
which is what almost every published glass snippet does,
Apple's own included. It is here so the two can be judged
against each other on the same ground rather than taken on
trust, and it applies only inside a test board. */
.gtry[data-rim="flat"] .lab::before,
.gtry[data-rim="flat"] .gcard::before,
.gtry[data-rim="flat"] .cmd::before,
.gtry[data-rim="flat"] .gpane::before,
.gtry[data-rim="flat"] .gnav::before,
.gtry[data-rim="flat"] .gdock::before {
border-color: var(--try-edge, transparent);
background: none;
-webkit-mask: none;
mask: none;}
// bencho source (MIT). npm i @tabler/icons-react motion react · Tailwind CSS v4
// ── blocks/dock/GlassDock.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/dock/GlassDock.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 { useLayoutEffect, useRef, useState } from "react";
import { IconBookmark as Bookmark, IconFolder as Folder, IconHome as House, IconSearch as Search, IconUser as User } from "@tabler/icons-react";
type Item = { key: string; label: string; Icon: typeof House };
/* the dock's set; the icon bar (GlassIconBar.tsx) carries the same
five: they are the same navigation in two different materials */
const DOCK: Item[] = [
{ key: "home", label: "Home", Icon: House },
{ key: "search", label: "Search", Icon: Search },
{ key: "files", label: "Files", Icon: Folder },
{ key: "saved", label: "Saved", Icon: Bookmark },
{ key: "you", label: "You", Icon: User },
];
/* ══ dock, distance based magnification ═══════════════════
Scale falls off with distance from the cursor rather than
applying only to the hovered item, which is what stops it
reading as a row of buttons that happen to grow. */
export function GlassDock({
/* what the glyph under the cursor grows to */
magnify = 1.32,
/* how many neighbours either side feel it. This is the knob
that decides whether the dock reads as a row of buttons
that happen to grow or as a sheet being pushed up from
underneath — at 0 it is the former, and no amount of
magnification rescues it. */
spread = 2,
/* how far the nearest glyph rises out of the bar */
lift = 8,
/* the name that appears over whatever is under the cursor */
labels = true,
}: {
magnify?: number;
spread?: number;
lift?: number;
labels?: boolean;
}) {
const [hover, setHover] = useState<number | null>(null);
const [active, setActive] = useState(DOCK[0].key);
/* ── THE BAR READS THE POINTER, THE ITEMS DO NOT ─────────
Each item used to carry its own onMouseEnter, which fails
on a touch screen twice over. A mouse event is the smaller
half of it — the real problem is that a touch is captured
to whatever it started on, so sliding a finger along the
dock keeps sending every event to the first icon you
landed on and nothing else ever learns the finger arrived.
One handler on the bar, and the index comes from where the
pointer is: the nearest item centre to the pointer's x.
Measured rather than derived from the index, because the
items are not all the same width once one of them is
magnified — the geometry moves as you sweep, which is
exactly what makes a dock a dock, and an arithmetic guess
would lag it. */
const bar = useRef<HTMLElement | null>(null);
const down = useRef(false);
/* set when a finger has already chosen on lift, so the click
the browser sends afterwards — aimed at whichever item the
touch STARTED on, which is not the one it ended over — does
not undo the choice. A mouse never sets it. */
const chose = useRef(false);
const at = (clientX: number) => {
const items = bar.current?.querySelectorAll(".gdock-item");
if (!items?.length) return null;
let best = 0;
let gap = Infinity;
items.forEach((el, i) => {
const b = el.getBoundingClientRect();
const d = Math.abs(clientX - (b.left + b.width / 2));
if (d < gap) { gap = d; best = i; }
});
return best;
};
/* Crossing onto a glyph, not hovering one: a sound on hover
fires on every pixel of a sweep. Quiet, floored, and
pitched by position so running along the dock is a scale. */
const to = (i: number | null) => {
setHover((_was) => {
return i;
});
};
const track = (e: React.PointerEvent) => {
/* a mouse magnifies on hover, the way it always did; a
finger has to be down, or the bar would answer a scroll
passing over it */
if (e.pointerType !== "mouse" && !down.current) return;
to(at(e.clientX));
};
return (
<nav
className="gdock"
aria-label="Dock"
ref={bar}
/* ── CAPTURE PHASE, and no pointer capture ───────────
Two different things with confusingly similar names.
The phase is capture because each item stops
pointerdown propagating — it has to, or the wall card
behind it treats a press on the dock as a press on the
card. Bubbling handlers here never ran: measured, the
magnification sat on item 0 through a full sweep.
Capture runs top-down, before the child can stop it.
What this does NOT do is call setPointerCapture. The
touch is already captured to the item it began on
whether we ask or not, and those events reach here
with their real coordinates, which is all this needs.
Capturing on the bar as well would retarget the click
and take it from the item — breaking the mouse to fix
the finger. */
onPointerDownCapture={(e) => {
down.current = true;
/* ── disarmed HERE, not by the click ────────────────
`chose` used to be cleared by the click it was meant
to swallow, which assumes a click always follows a
touch. It does not: a finger that lands on one item
and lifts over another is a drag, and a browser is
entitled to send no click at all. Measured — the flag
stayed armed and ate the next real mouse click, so
the dock ignored the first thing you pressed after
any touch sweep. Cleared at the start of the next
gesture instead, which is true whatever the browser
decided to do with the last one. */
chose.current = false;
to(at(e.clientX));
}}
onPointerMoveCapture={track}
/* ── and the touch has to CHOOSE something ────────────
With the bar holding the capture the button underneath
never gets its click, so the lift is where a finger
picks: whichever item it came to rest over. A mouse is
untouched by this — it still clicks the button. */
onPointerUpCapture={(e) => {
if (down.current && e.pointerType !== "mouse") {
const i = at(e.clientX);
if (i !== null) {
chose.current = true;
if (DOCK[i].key !== active) {
setActive(DOCK[i].key);
}
}
}
down.current = false;
if (e.pointerType !== "mouse") to(null);
}}
onPointerCancelCapture={() => { down.current = false; to(null); }}
onPointerLeave={() => { if (!down.current) to(null); }}
>
{DOCK.map(({ key, label, Icon }, i) => {
const d = hover === null ? 99 : Math.abs(i - hover);
/* A raised cosine over the reach, rather than the three
hand-picked steps this used to carry. Those could not
be made adjustable without also picking every
intermediate value by hand, and a curve is what the
effect was always imitating: 1 under the cursor,
easing to 0 at the edge of the reach, and flat zero
past it. */
const f =
d > spread ? 0 : (1 + Math.cos((Math.PI * d) / (spread + 1))) / 2;
const scale = 1 + (magnify - 1) * f;
return (
<button
key={key}
className="gdock-item"
aria-label={label}
aria-current={active === key ? "page" : undefined}
data-near={d <= 1 ? d : undefined}
data-active={active === key}
/* Crossing onto a glyph, not hovering one: a sound
on hover fires on every pixel of a mouse sweep.
Quiet, floored, and pitched by position so
running along the dock is a scale. */
onClick={() => {
/* the lift already chose — see `chose` */
if (chose.current) return;
setActive(key);
}}
onPointerDown={(e) => e.stopPropagation()}
>
{/* the glyph magnifies, not the button. Scaling the
whole item dragged the dot and the label along
with it — the label ended up 15px further from
the bar purely as a side effect of the zoom. */}
<span
className="gdock-glyph"
style={{ transform: `translateY(${-lift * f}px) scale(${scale})` }}
>
<Icon size={20} strokeWidth={2} />
</span>
<span className="gdock-dot" data-on={active === key} />
</button>
);
})}
{labels && <DockTip bar={bar} at={hover} />}
</nav>
);
}
/* ── ONE TIP THAT TRAVELS ─────────────────────────────────
After the avatar tooltip in transitions.dev's share dialog: not a
label per icon blinking on and off, but one pill that slides
along to whichever icon is under the pointer and changes width to
fit the new word as it goes, both on one short curve. It keeps the
last word while it fades, so leaving the dock does not empty it
mid-fade. Its place is read off the item it sits over, centre to
centre, since a magnified dock does not lay out evenly. */
function DockTip({ bar, at }: { bar: React.RefObject<HTMLElement | null>; at: number | null }) {
const [last, setLast] = useState(0);
const [place, setPlace] = useState<{ x: number; w: number } | null>(null);
const word = useRef<HTMLSpanElement>(null);
/* the first placing must not slide in from the bar's left edge:
until it has been placed once it moves without a transition */
const [ready, setReady] = useState(false);
if (at !== null && at !== last) setLast(at);
useLayoutEffect(() => {
const nav = bar.current;
const item = nav?.querySelectorAll<HTMLElement>(".gdock-item")[last];
const text = word.current;
if (!nav || !item || !text) return;
/* offsetLeft is layout, so the glyph's own scale does not skew it */
const w = Math.ceil(text.scrollWidth) + 24;
setPlace({ x: item.offsetLeft + item.offsetWidth / 2 - w / 2, w });
}, [last, bar]);
useLayoutEffect(() => {
if (!place || ready) return;
const id = requestAnimationFrame(() => setReady(true));
return () => cancelAnimationFrame(id);
}, [place, ready]);
return (
<span
className="gdock-tip"
aria-hidden="true"
data-on={at !== null && !!place}
data-ready={ready || undefined}
style={place ? { width: place.w, transform: `translateX(${place.x}px)` } : undefined}
>
<span ref={word}>{DOCK[last].label}</span>
</span>
);
}Regler · HTML · CSS · JS
Bearbeite den Code und stimme ihn mit den Reglern ab. Die Vorschau aktualisiert sich beim Tippen.

Diese Komponente läuft aus einem fertigen Bundle, daher ist ihr Skript hier schreibgeschützt. Bearbeite HTML und CSS; der vollständige Quellcode steht im Tab Code.
Bearbeite jede Komponente live, stimme sie mit Reglern ab, lade den vollständigen Quellcode herunter und kopiere die erweiterten Prompts.
49 $ einmaligPlatzhalterpreis
Testmodus: Es wird nichts wirklich bezahlt.
Kostenlos: Vorschau, Kopier-Buttons und Lektionsnotizen.
Eine klare Form, eine kräftige Farbe und ein kurzes Drück-Feedback wirken greifbar.
Hauptaktionen, Handlungsaufrufe und Werkzeugleisten.
Ändere Rundung, Innenabstand und Dauer des Hover-Übergangs.
Füge die Komponente „Magnifying dock“ aus Bencho (github.com/cabralorenzo/bencho) (MIT) in meine React- und Tailwind-CSS-App ein. Quelldatei: https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/dock/GlassDock.tsx. Eine klare Form, eine kräftige Farbe und ein kurzes Drück-Feedback wirken greifbar. Einsatz: Hauptaktionen, Handlungsaufrufe und Werkzeugleisten. Einstellbare Werte: Ändere Rundung, Innenabstand und Dauer des Hover-Übergangs. Unterstütze helles und dunkles Theme und beachte prefers-reduced-motion. Behalte den MIT-Lizenzhinweis bei.
Ein längerer Prompt mit Schritten für Feinabstimmung, Barrierefreiheit und Einbindung.