1. Compute neighbor scale with a Gaussian curve
Given the cursor's clientX and each icon's horizontal center cx, compute d = Math.abs(clientX - cx). Map d through Math.exp(-(d * d) / (2 * sigma * sigma)) where sigma (~75px) controls how wide the wave spreads.
When d = 0, the curve returns 1.0 (full magnification); 75px away it returns ~0.61; 150px away it gently returns to ~0.13 with zero sharp kinks.
import { useRef, useState } from "react";
const ITEMS = ["Home", "Search", "Inbox", "Calendar", "Settings"];
const BASE = 44;
const MAX_EXTRA = 26;
const SIGMA = 72;
export function InteractiveDock() {
const [mouseX, setMouseX] = useState<number | null>(null);
const refs = useRef<(HTMLButtonElement | null)[]>([]);
const sizeFor = (index: number) => {
if (mouseX === null) return BASE;
const el = refs.current[index];
if (!el) return BASE;
const r = el.getBoundingClientRect();
const dist = Math.abs(mouseX - (r.left + r.width / 2));
const influence = Math.exp(-(dist * dist) / (2 * SIGMA * SIGMA));
return BASE + MAX_EXTRA * influence;
};
return (
<div
role="toolbar"
aria-label="App dock"
onPointerMove={(e) => e.pointerType !== "touch" && setMouseX(e.clientX)}
onPointerLeave={() => setMouseX(null)}
className="inline-flex h-16 items-end gap-2 rounded-2xl border bg-white px-3 pb-2 shadow-sm"
>
{ITEMS.map((label, i) => {
const size = sizeFor(i);
return (
<button
key={label}
ref={(el) => { refs.current[i] = el; }}
type="button"
aria-label={label}
style={{ width: size, height: size }}
className="grid shrink-0 place-items-center rounded-xl bg-zinc-900 text-xs font-bold text-white transition-[width,height] duration-75"
>
{label[0]}
</button>
);
})}
</div>
);
}2. Add roving keyboard focus inside role='toolbar'
Following the WAI-ARIA Toolbar pattern, Tab should enter the dock once, and ArrowLeft / ArrowRight should move focus between dock buttons cleanly. Keep the container anchored to items-end so icons grow upward rather than pushing layout down.
Accessibility checklist
Tick each one off as you check your build. Your ticks stay in this browser.
0 of 3 checked
Build it yourself or install it
Build it yourself when
A quick 4–5 icon footer bar with simple CSS transition smoothing.
Install Kipluo when
You want zero-re-render spring sizing, floating tooltips, roving tabindex, and pitched tick audio across icons.