Components68 / 118
Look Button
A quiet button with an eye that's watching you. At rest its pupil follows your cursor around the page; hover and it pops up to white with a jelly wobble, the eye blinks hello and keeps blinking now and then. Press to squeeze it shut, let go and it pops wide open.
ButtonButtonIconIconCursor trackingCursor trackingSpringsSpringsSquash & stretchSquash & stretchGSAPGSAP
Move around, then hoverPress and hold
Tweak
LIVELIVEText
Look
48px
Page
Eye
Follows the cursor
Usage
Follows your tweaks.
usage.tsx
import { LookButton } from "@/components/inreact/look-button";
export function Preview() {
return <LookButton onClick={() => openPreview()} size={48} />;
}Install with the CLI
TS + Tailwind
npx shadcn@latest add https://inreact.vercel.app/r/look-button.jsonOr copy the source
Install the dependencies, then save this as components/inreact/look-button.tsx.
terminal
npm install gsapcomponents/inreact/look-button.tsx
"use client";
import { gsap } from "gsap";
import { useEffect, useId, useRef } from "react";
/**
* Look Button: a quiet button with an eye that's watching you.
*
* At rest it's a soft grey chip, and its pupil follows your cursor around the
* page. Hover it and the button pops up to white with a jelly wobble (squash
* and stretch), the eye blinks hello (the lid really closes, then springs
* open a touch too wide), and it keeps blinking now and then while you stay.
* Press it and the eye squeezes shut; let go and it pops open wide. GSAP.
*
* <LookButton label="Look" onClick={preview} />
*/
export interface LookButtonProps {
label?: string;
href?: string;
onClick?: () => void;
/** Height, px. */
size?: number;
/** Light or dark page. */
tone?: "light" | "dark";
/** The pupil follows the cursor across the page. */
watch?: boolean;
className?: string;
}
const reduced = () => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
// the eye, in a 24×24 box: lids are two quadratic curves between the corners;
// "open" lifts the upper lid (0 = shut, which leaves just the lower curve)
const L = 1.8, R = 22.2, MID = 12, LOW = 11.2;
const lid = (open: number) => {
const up = MID + LOW - 2 * LOW * open; // control point of the upper lid
return `M${L} ${MID}Q12 ${up.toFixed(3)} ${R} ${MID}Q12 ${MID + LOW} ${L} ${MID}Z`;
};
export function LookButton({ label = "Look", href, onClick, size = 44, tone = "light", watch = true, className }: LookButtonProps) {
const rootRef = useRef<HTMLElement | null>(null);
const bodyRef = useRef<HTMLSpanElement>(null);
const eyeRef = useRef<SVGPathElement>(null);
const clipRef = useRef<SVGPathElement>(null);
const pupilRef = useRef<SVGGElement>(null);
const clipId = `lk${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
useEffect(() => {
const root = rootRef.current, body = bodyRef.current, eye = eyeRef.current, clip = clipRef.current, pupil = pupilRef.current;
if (!root || !body || !eye || !clip || !pupil) return;
const still = reduced();
const st = {
open: 1,
// gaze (pupil offset, -1..1) with a quick, saccade-like spring
gx: 0, gy: 0, vgx: 0, vgy: 0, tgx: 0, tgy: 0,
// the body: size and jelly (s > 0 stretches tall), both springs
u: 1, vu: 0, tu: 1,
s: 0, vs: 0,
hover: 0,
};
// ---- blinking
let blinkTl: gsap.core.Timeline | null = null;
let nextBlink: gsap.core.Tween | null = null;
const blink = (twice = false) => {
if (still) return;
blinkTl?.kill();
blinkTl = gsap.timeline();
const once = (tl: gsap.core.Timeline) =>
tl.to(st, { open: 0, duration: 0.085, ease: "power2.in" })
// springs back open a touch too wide, then settles
.to(st, { open: 1, duration: 0.5, ease: "elastic.out(1.05, 0.45)" });
once(blinkTl);
if (twice) {
blinkTl.to(st, { open: 0, duration: 0.08, ease: "power2.in" }, 0.2).to(st, { open: 1, duration: 0.5, ease: "elastic.out(1.05, 0.45)" });
}
};
const schedule = () => {
nextBlink?.kill();
nextBlink = gsap.delayedCall(1.1 + Math.random() * 1.6, () => {
if (!st.hover) return;
blink(Math.random() < 0.25);
schedule();
});
};
const last = { eye: "", pupil: "", body: "" };
const tick = (_t: number, ms: number) => {
const dt = Math.min(ms / 1000, 1 / 30) / 2;
for (let i = 0; i < 2; i++) {
if (still) {
st.gx = st.tgx; st.gy = st.tgy; st.u = st.tu; st.s = 0;
break;
}
// gaze: fast and only slightly springy, like an eye
const kg = 520, cg = 2 * 0.62 * Math.sqrt(kg);
st.vgx += (kg * (st.tgx - st.gx) - cg * st.vgx) * dt; st.gx += st.vgx * dt;
st.vgy += (kg * (st.tgy - st.gy) - cg * st.vgy) * dt; st.gy += st.vgy * dt;
// body size: overshoots on the pop
const ku = 260, cu = 2 * 0.36 * Math.sqrt(ku);
st.vu += (ku * (st.tu - st.u) - cu * st.vu) * dt; st.u += st.vu * dt;
// jelly: wobbles after every kick
const ks = 380, cs = 2 * 0.22 * Math.sqrt(ks);
st.vs += (-ks * st.s - cs * st.vs) * dt; st.s += st.vs * dt;
}
const s = Math.max(-0.2, Math.min(0.2, st.s));
const bt = `scale(${(st.u * (1 - s)).toFixed(4)},${(st.u * (1 + s)).toFixed(4)})`;
if (bt !== last.body) {
body.style.transform = bt;
last.body = bt;
}
const path = lid(st.open);
if (path !== last.eye) {
eye.setAttribute("d", path);
clip.setAttribute("d", path);
last.eye = path;
}
// the pupil sits a little lower as the lid comes down
const px = MID + st.gx * 4.4, py = MID + st.gy * 2.2 + (1 - Math.min(1, st.open)) * 1.2;
const pt = `translate(${px.toFixed(2)} ${py.toFixed(2)})`;
if (pt !== last.pupil) {
pupil.setAttribute("transform", pt);
last.pupil = pt;
}
};
gsap.ticker.add(tick);
// the eye follows the cursor anywhere on the page
const onLook = (e: PointerEvent) => {
const r = eye.ownerSVGElement!.getBoundingClientRect();
const dx = e.clientX - (r.left + r.width / 2), dy = e.clientY - (r.top + r.height / 2);
const d = Math.hypot(dx, dy);
const reach = Math.min(1, d / 140); // looks straight at you when you're close
st.tgx = d ? (dx / d) * reach : 0;
st.tgy = d ? (dy / d) * reach : 0;
};
const onAway = () => {
st.tgx = st.tgy = 0;
};
if (watch) {
window.addEventListener("pointermove", onLook, { passive: true });
document.documentElement.addEventListener("pointerleave", onAway);
}
const onEnter = () => {
st.hover = 1;
root.dataset.on = "";
st.tu = 1.06;
st.vs += 2.4; // the pop stretches it up, then it wobbles down
blink();
schedule();
};
const onLeave = () => {
st.hover = 0;
delete root.dataset.on;
st.tu = 1;
st.vs -= 1.2;
nextBlink?.kill();
};
const onDown = () => {
if (still) return;
blinkTl?.kill();
gsap.to(st, { open: 0.12, duration: 0.12, ease: "power2.out", overwrite: true }); // squeeze shut
st.tu = 0.97;
st.vs -= 2.2; // squashes flat
};
const onUp = () => {
if (still) return;
gsap.to(st, { open: 1, duration: 0.6, ease: "elastic.out(1.2, 0.4)", overwrite: true }); // pops wide open
st.tu = st.hover ? 1.06 : 1;
st.vs += 2.8;
};
root.addEventListener("pointerenter", onEnter);
root.addEventListener("pointerleave", onLeave);
root.addEventListener("pointerdown", onDown);
root.addEventListener("pointerup", onUp);
root.addEventListener("focus", onEnter);
root.addEventListener("blur", onLeave);
return () => {
gsap.ticker.remove(tick);
blinkTl?.kill();
nextBlink?.kill();
gsap.killTweensOf(st);
window.removeEventListener("pointermove", onLook);
document.documentElement.removeEventListener("pointerleave", onAway);
root.removeEventListener("pointerenter", onEnter);
root.removeEventListener("pointerleave", onLeave);
root.removeEventListener("pointerdown", onDown);
root.removeEventListener("pointerup", onUp);
root.removeEventListener("focus", onEnter);
root.removeEventListener("blur", onLeave);
};
}, [watch]);
const H = size;
const light = tone === "light";
const cls = ["group/look relative inline-grid shrink-0 select-none place-items-center outline-none [-webkit-tap-highlight-color:transparent]", className].filter(Boolean).join(" ");
const style = {
height: H,
["--rest" as string]: light ? "#eceef3" : "#1b1c20",
["--on" as string]: light ? "#ffffff" : "#f4f4f6",
["--ink" as string]: light ? "#8a8d96" : "#7d7f87",
["--ink-on" as string]: "#111114",
};
const inner = (
<span
ref={bodyRef}
className="relative flex h-full items-center gap-[0.42em] bg-[var(--rest)] text-[var(--ink)] transition-[background-color,color,box-shadow] duration-300 ease-out will-change-transform group-data-[on]/look:bg-[var(--on)] group-data-[on]/look:text-[var(--ink-on)] group-data-[on]/look:shadow-[0_1px_2px_rgba(16,18,30,.06),0_6px_16px_rgba(16,18,30,.07),0_16px_34px_rgba(16,18,30,.06)] group-focus-visible/look:ring-2 group-focus-visible/look:ring-current/25"
style={{ padding: `0 ${Math.round(H * 0.58)}px`, borderRadius: Math.round(H * 0.24), fontSize: Math.round(H * 0.41), fontWeight: 500, letterSpacing: "-0.005em" }}
>
<svg viewBox="0 0 24 24" aria-hidden="true" style={{ width: Math.round(H * 0.5), height: Math.round(H * 0.5), overflow: "visible" }}>
<defs>
<clipPath id={clipId}>
<path ref={clipRef} d={lid(1)} />
</clipPath>
</defs>
<g clipPath={`url(#${clipId})`}>
<g ref={pupilRef} transform={`translate(${MID} ${MID})`}>
<circle r="3.25" fill="currentColor" />
<circle cx="1.05" cy="-1.05" r="0.95" fill="var(--on)" className="opacity-0 transition-opacity duration-300 group-data-[on]/look:opacity-100" />
</g>
</g>
<path ref={eyeRef} d={lid(1)} fill="none" stroke="currentColor" strokeWidth="2" strokeLinejoin="round" strokeLinecap="round" />
</svg>
<span className="whitespace-nowrap">{label}</span>
</span>
);
return href ? (
<a ref={(el) => void (rootRef.current = el)} href={href} onClick={onClick} className={cls} style={style}>
{inner}
</a>
) : (
<button ref={(el) => void (rootRef.current = el)} type="button" onClick={onClick} className={cls} style={style}>
{inner}
</button>
);
}
export default LookButton;
One prompt, any AI agent
Paste into Claude Code, Codex, Cursor or Windsurf. It carries your tweaks and the full source, so the agent installs it exactly.
Props
7 propslabelstringButton text.default "Look"default "Look"hrefstringRender a link.onClick() => voidClick handler.sizenumberHeight, px.default 44default 44tone"light" | "dark"Colours for the page.default "light"default "light"watchbooleanThe pupil follows the cursor.default truedefault trueclassNamestringExtra classes.