Impeccable

Peephole button

A glass button with a picture window that opens on hover into the whole image or your brand color. Use it on Contact or Gallery with a real photo.

ButtonGlassImage revealAvatarNo extra packagesLight + darkMobile

npx shadcn@latest add https://impeccableui.vercel.app/r/peephole-button.json
Hover the button to open the picture, or press Use my picture to try it with your own. On a phone, press and hold it.

Run it in a project set up with shadcn. No other packages needed. Or open and copy the file into components/ui/peephole-button.tsx.

Types

Two types. Reveal is frosted glass tinted by your picture, and hovering opens the whole picture. Fill keeps your avatar or logo in the slot, and hovering pours your brand color across the button.

Reveal · variant="reveal"
Fill · variant="fill"
// Reveal (the default): frosted glass tinted by the picture; hover opens the whole picture.
<PeepholeButton image="/fields.jpg">Take a peek</PeepholeButton>

// Fill: your avatar in the slot; hover pours your brand color out of it.
<PeepholeButton variant="fill" image="/ava.jpg" side="right">Talk to Ava</PeepholeButton>

Slot

The slot is the little window. Make it a circle or a square, put it on the left or the right, and give it any size from 20 to 80px. A square slot gives the button rounded corners to match.

shape="circle"
shape="square"
side="right"
slotSize={28}
shape="square" slotSize={48}
<PeepholeButton image="/dunes.jpg">Circle slot</PeepholeButton>
<PeepholeButton image="/tide.jpg" shape="square">Square slot</PeepholeButton>
<PeepholeButton image="/fields.jpg" side="right">On the right</PeepholeButton>
<PeepholeButton variant="fill" image="/kai.jpg" slotSize={28}>Small slot</PeepholeButton>
<PeepholeButton variant="fill" image="/ava.jpg" shape="square" slotSize={48} side="right">Big square</PeepholeButton>

Prompts

Paste one into Claude Code, Cursor or any AI coding tool. Install adds this exact button and asks only where it goes and which picture to use. Blend asks four short questions (where and which picture, which type, the slot, and the fill color), then fits it to your product without changing how it opens.

# Peephole button

A 1-file React component from Impeccable. Add it to this project so it works and looks exactly like the source below, in the one place I choose, and change nothing else.

A glassy button with a small window (the slot) that shows a picture. On hover the window stretches open across the whole button. In the "reveal" type the whole picture shows through the glass; in the "fill" type my avatar or logo stays in the slot while my brand color pours out of it, and the label turns white exactly where the color has reached.

## Before you build: one question

Look through this project first: its buttons and calls to action, its profile, team, contact and gallery areas, and the pictures it already has (avatars, product shots, cover images). Then ask me this in one message and wait for my answer:

- **Where should it go, and which picture should it show?** Suggest the 1–3 buttons it could replace or the spots it fits best (for example a "Talk to us" button with a team member's avatar, a "View gallery" or "See the work" button with a cover image, or a profile action with the person's photo), each with a picture you found in my project. Keep the button's label, link and click handler. I can pick one, name another, or give you a different picture.
  *Why: the picture is the whole point of this button, so it belongs where a real picture says something about what the click opens.*

Ask nothing else. If I say *skip*, use the best suggestion. Use the `"reveal"` type for a big picture (a photo, a cover) and `"fill"` for an avatar or logo, with the slot on the left and every other prop at its default.

## Keep it as it is

The glass button with a small picture window, the window stretching open from the slot to the whole button on hover, and its sizes and timing are the design. Keep them exactly as in the source. If something doesn't fit my project, tell me instead of changing it.

- Add only the component file and the one place I picked. If it replaces an existing button, keep that button's label, link, click handler and form wiring. Don't add packages, change other files, or restyle anything.
- Don't add the demo parts from the Impeccable website: the dotted card behind the button, the "Use my picture" and "Reset" buttons, the eye icon in the slot and the captions under the buttons. The website's sample pictures are not part of it either: use a picture from my project.

## Fastest path

If this project has a `components.json` (shadcn), run `npx shadcn@latest add https://impeccableui.vercel.app/r/peephole-button.json`.
If the command succeeds, only fix import paths to match this project and skip ahead. If it fails or there is no `components.json`, build it by hand as below.

## Build it

- Stack: React 18 or 19 with TypeScript. No other packages and no animation loop: the opening is one CSS `clip-path` transition, and the rest is plain CSS in the component.
- JavaScript project? Name the file `peephole-button.jsx` and remove the type annotations; nothing else changes.
- Create this file, in this project's usual place for components:
  - `components/ui/peephole-button.tsx`
- Keep these exports and their names: `PeepholeButton`, `PeepholeButtonProps`.
- Keep `"use client"` at the top in Next.js App Router projects. In other setups it is harmless.
- Keep the tuning values at the top exactly as written: `MIN_H` (44px), `GAP` (6px round the slot), `SLOT_MIN` and `SLOT_MAX` (20 to 80px), `LINGER_MS` (700ms), and the whole `CSS` block: open 560ms on `cubic-bezier(.22,1,.36,1)`, close 420ms on `cubic-bezier(.4,0,.2,1)`, the 16px blur of the frosted glass, the picture's 1.12 zoom that settles to 1, and the shade that fades in under the label. They are the design and its timing.
- Keep the nested corners: the slot's corner radius is the button's radius minus the space around the slot, so the two always nest.
- Keep the fallbacks: with `prefers-reduced-motion: reduce` it switches open and closed with no stretch. On touch screens, pressing opens it and it closes 700ms after the finger lifts. Keyboard focus opens it and shows a ring in the page's text color. A disabled button stays closed. A picture that is missing or fails to load leaves plain glass and an empty slot, never a broken image.

## Use it

```tsx
"use client";
import { PeepholeButton } from "@/components/ui/peephole-button";

export function TalkToUs() {
  return (
    <PeepholeButton variant="fill" image="/team/ava.jpg" side="right" onClick={() => openChat()}>
      Talk to Ava
    </PeepholeButton>
  );
}
```

- It is a real `<button>` and takes every button prop (`onClick`, `type`, `disabled`, `aria-*`). For a link, put it inside the link or call the router in `onClick`.
- `image` is any image URL the page can load (a file in `public/`, an imported image's `.src`, or a remote URL the project already allows). Use a picture at least twice the button's size so it stays sharp when open.
- `className` and `style` go on the button itself. Its width follows the label; everything happens inside it, so it needs no extra room.

## How the button works

Read this before you touch anything, so you know what the code does and why it must stay as it is.

1. **The shape.** The button is 44px tall (more if the slot is bigger than 32px, always keeping 6px round it). The slot sits at the `side` I chose. With `shape="circle"` it is a round slot in a pill; with `shape="square"` it is a rounded square in a button with `radius` corners (12px), and the slot's corners are that radius minus the 6px gap. The label gets extra padding on the slot's side so it never sits under the slot.
2. **Reveal at rest.** The glass is a heavily blurred, slightly zoomed copy of the same picture, under a light shade (darker in dark mode), so it always takes the picture's colors. A soft white sheen covers its top half and a thin bright edge runs round it; both are much fainter in dark mode, so the button looks the same in both themes. Inside the slot the same picture shows sharp. The label is white with a soft shadow.
3. **Fill at rest.** The glass is clear: a frosted white in light mode and a faint white in dark mode, over whatever is behind it. My avatar or logo fills the slot. The label is black in light mode and white in dark mode.
4. **Opening.** One layer holds the sharp picture (reveal) or the fill color plus a white copy of the label (fill). It is clipped to the slot's exact shape at rest. On hover, touch press or keyboard focus, the clip widens from the slot to the whole button in 560ms with a soft ease out, so the window looks like it stretches open from where it sits. In reveal, the picture settles from a 1.12 zoom to its real size and a shade fades in under the label. In fill, the white label copy sits in exactly the same place as the normal label, so the label turns white exactly where the color has reached.
5. **Closing.** Moving away shrinks the window back into the slot in 420ms. On touch screens it closes 700ms after the finger lifts, so a quick tap still shows it.
6. **Glass on top.** The sheen and the edge sit above everything, so the button still reads as glass when it is open.

## Check

- It type-checks and the page renders with no console errors.
- At rest the button is glass with the picture showing only inside the slot. Hovering stretches the window open across the whole button in about half a second (reveal: the whole picture shows; fill: the brand color pours in and the label turns white as it passes). Moving away closes it in about 0.4 seconds.
- It looks right in light and dark mode (check both): the glass, its edge and the label read on both.
- On a phone, pressing opens it, it closes a moment after the finger lifts, the button works on the first tap, and there is no sideways scroll.
- With `prefers-reduced-motion: reduce`, it switches open and closed with no stretch.
- Nothing else on the site looks or behaves differently.
- Finish with a short report: the files you added or changed, where it's placed and which picture it shows, and every place where you had to do something differently from the source, and why.

## Source

The reference implementation. Copy it as-is, then apply only the changes listed above.

### `components/ui/peephole-button.tsx`

```tsx
"use client";

/**
 * Peephole button, from Impeccable.
 *
 * A glassy button with a small window (the slot) that shows a picture. Two types:
 *
 *   - "reveal": the button is frosted glass tinted by your picture, and the picture
 *     shows sharp only inside the slot. On hover the slot stretches open across the
 *     whole button and the full picture shows through the glass.
 *   - "fill": your own picture (an avatar or logo) sits in the slot on a clear glass
 *     button. On hover a fill of your brand color pours out of the slot across the
 *     button, and the label turns white exactly where the color has reached.
 *
 * The slot can be a circle or a square, sit on the left or the right, and take
 * any size. Phones have no hover, so pressing opens it and it closes a moment
 * after the finger lifts. Keyboard focus opens it too.
 *
 * No packages and no animation loop: the opening is one CSS clip-path transition.
 */

import {
  forwardRef,
  useEffect,
  useRef,
  useState,
  type ButtonHTMLAttributes,
  type CSSProperties,
  type PointerEvent,
  type ReactNode,
} from "react";

export type PeepholeButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
  /** The picture: the whole picture in "reveal", your avatar or logo in "fill". Any image URL. */
  image?: string;
  /** "reveal" opens the whole picture on hover. "fill" pours your brand color out of the slot on hover. Default "reveal". */
  variant?: "reveal" | "fill";
  /** The slot's shape. "circle" makes a round slot in a pill. "square" makes a rounded square slot in a rounded button. Default "circle". */
  shape?: "circle" | "square";
  /** Which end the slot sits at. Default "left". */
  side?: "left" | "right";
  /** The slot's size in px, from 20 to 80. The button grows to keep 6px around it. Default 32. */
  slotSize?: number;
  /** The button's corner radius in px when shape is "square". The slot's corners follow, minus the space around it. Default 12. */
  radius?: number;
  /** A small icon drawn in the middle of the slot, over the picture. */
  icon?: ReactNode;
  /** "fill" only: the color that pours out of the slot. Any CSS color, including var(--…). Default the Impeccable violet. */
  fillColor?: string;
  /** "fill" only: the label color where the fill has reached. Default white. */
  fillTextColor?: string;
  /** The label color at rest. Default white in "reveal", and black or white to suit the theme in "fill". */
  textColor?: string;
};

/* ---------- tuning (the design: keep as written) ---------- */

const MIN_H = 44; // px: the button's height, unless the slot needs more
const GAP = 6; // px: the least space around the slot, so the picture has room to breathe
const SLOT_MIN = 20; // px
const SLOT_MAX = 80; // px
const LINGER_MS = 700; // on touch: how long it stays open after the finger lifts

/** Styles that can't be inline: layers, the open and close transitions, theme, focus, disabled and reduced motion. */
const CSS = `
.iph { --iph-theme-text: rgb(10 10 10); --iph-theme-glass: rgb(255 255 255 / .55); --iph-theme-edge: rgb(0 0 0 / .08); --iph-theme-wash: rgb(0 0 0 / .1); --iph-theme-empty: rgb(0 0 0 / .08); --iph-sheen: rgb(255 255 255 / .22); --iph-top: rgb(255 255 255 / .35); --iph-top-pic: rgb(255 255 255 / .45); --iph-edge-pic: rgb(255 255 255 / .22); }
:is(.dark, [data-theme="dark"]) .iph { --iph-theme-text: rgb(255 255 255); --iph-theme-glass: rgb(255 255 255 / .07); --iph-theme-edge: rgb(255 255 255 / .12); --iph-theme-wash: rgb(0 0 0 / .28); --iph-theme-empty: rgb(255 255 255 / .1); --iph-sheen: rgb(255 255 255 / .05); --iph-top: rgb(255 255 255 / .1); --iph-top-pic: rgb(255 255 255 / .16); --iph-edge-pic: rgb(255 255 255 / .14); }
.iph { --iph-ease-open: cubic-bezier(.22,1,.36,1); --iph-ease-close: cubic-bezier(.4,0,.2,1); --iph-open: 560ms; --iph-close: 420ms;
  position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 0; max-width: 100%;
  height: var(--iph-h); padding: 0 var(--iph-pr) 0 var(--iph-pl); border: 0; border-radius: var(--iph-r); overflow: hidden; isolation: isolate;
  background: var(--iph-theme-glass); -webkit-backdrop-filter: blur(14px) saturate(1.6); backdrop-filter: blur(14px) saturate(1.6);
  box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 6px 16px -4px rgb(0 0 0 / .14);
  color: var(--iph-text, var(--iph-theme-text)); font: inherit; font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: scale .18s cubic-bezier(.23,1,.32,1); }
.iph[data-variant="reveal"]:not([data-empty]) { color: var(--iph-text, rgb(255 255 255)); }
.iph[data-side="left"] { --iph-x0: var(--iph-i); --iph-x1: calc(100% - var(--iph-i) - var(--iph-s)); }
.iph[data-side="right"] { --iph-x0: calc(100% - var(--iph-i) - var(--iph-s)); --iph-x1: var(--iph-i); }
/* glass: a sheen on the top half and a bright edge, over everything */
.iph::after { content: ""; position: absolute; inset: 0; z-index: 5; border-radius: inherit; pointer-events: none;
  background: linear-gradient(to bottom, var(--iph-sheen), rgb(255 255 255 / 0) 55%);
  box-shadow: inset 0 0 0 1px var(--iph-theme-edge), inset 0 1px 0 var(--iph-top); }
.iph[data-variant="reveal"]::after { box-shadow: inset 0 0 0 1px var(--iph-edge-pic), inset 0 1px 0 var(--iph-top-pic); }
/* reveal: frosted glass tinted by the picture */
.iph-frost { position: absolute; inset: 0; z-index: 0; overflow: hidden; border-radius: inherit; clip-path: inset(0 round var(--iph-r)); pointer-events: none; }
.iph-frost img { width: 100%; height: 100%; object-fit: cover; scale: 1.4; filter: blur(16px) saturate(1.35); }
.iph-frost::after { content: ""; position: absolute; inset: 0; background: var(--iph-theme-wash); }
/* the window: shows the slot at rest and stretches over the whole button when open */
.iph-open { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; padding: 0 var(--iph-pr) 0 var(--iph-pl); pointer-events: none;
  clip-path: inset(var(--iph-i) var(--iph-x1) var(--iph-i) var(--iph-x0) round var(--iph-sr));
  transition: clip-path var(--iph-close) var(--iph-ease-close); }
.iph-pic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; scale: 1.12; transition: scale var(--iph-close) var(--iph-ease-close); }
.iph-scrim { position: absolute; inset: 0; background: linear-gradient(to bottom, rgb(0 0 0 / .18), rgb(0 0 0 / .42)); opacity: 0; transition: opacity var(--iph-close) var(--iph-ease-close); }
.iph-fill { position: absolute; inset: 0; background: var(--iph-fill, rgb(72 29 232)); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .25); }
.iph-empty { position: absolute; inset: 0; background: var(--iph-theme-empty); }
/* the slot's own ring, the avatar and the icon */
.iph-slot { position: absolute; z-index: 3; top: 50%; translate: 0 -50%; width: var(--iph-s); height: var(--iph-s); border-radius: var(--iph-sr); overflow: hidden; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .45); display: grid; place-items: center; color: rgb(255 255 255); }
.iph[data-side="left"] .iph-slot { left: var(--iph-i); }
.iph[data-side="right"] .iph-slot { right: var(--iph-i); }
.iph-slot > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.iph-slot > .iph-icon { position: relative; display: grid; place-items: center; width: 55%; height: 55%; filter: drop-shadow(0 1px 2px rgb(0 0 0 / .35)); }
.iph-slot > .iph-icon > svg { width: 100%; height: 100%; }
.iph[data-variant="fill"] .iph-slot { box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1); }
.iph-label { position: relative; z-index: 4; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iph[data-variant="reveal"]:not([data-empty]) .iph-label { text-shadow: 0 1px 2px rgb(0 0 0 / .35); }
.iph[data-variant="fill"] .iph-label { z-index: 1; }
.iph-open > .iph-label { color: var(--iph-fill-text, rgb(255 255 255)); }
/* open: on hover (mouse), on touch press, and on keyboard focus */
.iph[data-open] .iph-open { clip-path: inset(0 0 0 0 round var(--iph-r)); transition: clip-path var(--iph-open) var(--iph-ease-open); }
.iph[data-open] .iph-pic { scale: 1; transition: scale var(--iph-open) var(--iph-ease-open); }
.iph[data-open] .iph-scrim { opacity: 1; transition: opacity var(--iph-open) var(--iph-ease-open); }
@media (hover: hover) {
  .iph:hover:not(:disabled) .iph-open { clip-path: inset(0 0 0 0 round var(--iph-r)); transition: clip-path var(--iph-open) var(--iph-ease-open); }
  .iph:hover:not(:disabled) .iph-pic { scale: 1; transition: scale var(--iph-open) var(--iph-ease-open); }
  .iph:hover:not(:disabled) .iph-scrim { opacity: 1; transition: opacity var(--iph-open) var(--iph-ease-open); }
}
.iph:focus-visible .iph-open { clip-path: inset(0 0 0 0 round var(--iph-r)); transition: clip-path var(--iph-open) var(--iph-ease-open); }
.iph:focus-visible .iph-pic { scale: 1; }
.iph:focus-visible .iph-scrim { opacity: 1; }
.iph:active:not(:disabled) { scale: .97; }
.iph:focus-visible { outline: 2px solid var(--iph-theme-text); outline-offset: 3px; }
.iph:disabled { opacity: .5; cursor: not-allowed; }
@media (prefers-reduced-motion: reduce) {
  .iph, .iph .iph-open, .iph .iph-pic, .iph .iph-scrim, .iph:hover .iph-open, .iph:hover .iph-pic, .iph:hover .iph-scrim, .iph[data-open] .iph-open, .iph[data-open] .iph-pic, .iph[data-open] .iph-scrim, .iph:focus-visible .iph-open { transition: none; }
  .iph .iph-pic { scale: 1; }
  .iph:active:not(:disabled) { scale: 1; }
}`;

const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));

export const PeepholeButton = forwardRef<HTMLButtonElement, PeepholeButtonProps>(function PeepholeButton(
  {
    image,
    variant = "reveal",
    shape = "circle",
    side = "left",
    slotSize = 32,
    radius = 12,
    icon,
    fillColor,
    fillTextColor,
    textColor,
    children,
    className,
    style,
    type = "button",
    disabled,
    onPointerDown,
    onPointerUp,
    onPointerCancel,
    onPointerLeave,
    ...rest
  },
  ref,
) {
  // A picture that fails to load falls back to plain glass and an empty slot.
  const [failed, setFailed] = useState<string | null>(null);
  const pic = image && failed !== image ? image : null;
  const onError = () => setFailed(image ?? null);
  // A picture can fail before the page is interactive, when onError isn't listening yet: check once after mount.
  const btn = useRef<HTMLButtonElement | null>(null);
  useEffect(() => {
    const imgs = btn.current?.querySelectorAll("img") ?? [];
    for (const img of imgs) if (img.complete && img.naturalWidth === 0) setFailed(image ?? null);
  }, [image]);

  // Touch has no hover: a press opens it, and it closes a moment after the finger lifts.
  const [peek, setPeek] = useState(false);
  const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
  useEffect(() => () => clearTimeout(timer.current), []);
  const down = (e: PointerEvent<HTMLButtonElement>) => {
    onPointerDown?.(e);
    if (e.pointerType === "mouse" || disabled) return;
    clearTimeout(timer.current);
    setPeek(true);
  };
  const up = (e: PointerEvent<HTMLButtonElement>) => {
    if (e.type === "pointerup") onPointerUp?.(e);
    else if (e.type === "pointercancel") onPointerCancel?.(e);
    else onPointerLeave?.(e);
    if (e.pointerType === "mouse") return;
    clearTimeout(timer.current);
    timer.current = setTimeout(() => setPeek(false), LINGER_MS);
  };

  // Geometry: the slot keeps at least GAP px around it; nested corners follow outer radius minus the space between.
  const s = clamp(Number.isFinite(slotSize) ? slotSize : 32, SLOT_MIN, SLOT_MAX);
  const h = Math.max(MIN_H, s + GAP * 2);
  const i = (h - s) / 2;
  const square = shape === "square";
  const r = square ? clamp(Number.isFinite(radius) ? radius : 12, 0, h / 2) : h / 2;
  const sr = square ? Math.max(2, r - i) : s / 2;
  const label = children !== undefined && children !== null && children !== false && children !== "";
  const near = i + s + (label ? 10 : 0); // label padding on the slot's side
  const far = label ? (square ? 16 : 18) : i; // and on the other side (no label: just the slot, with even space round it)

  const fill = variant === "fill";

  return (
    <>
      <style>{CSS}</style>
      <button
        ref={(node) => {
          btn.current = node;
          if (typeof ref === "function") ref(node);
          else if (ref) ref.current = node;
        }}
        type={type}
        disabled={disabled}
        className={className ? `iph ${className}` : "iph"}
        data-variant={fill ? "fill" : "reveal"}
        data-side={side === "right" ? "right" : "left"}
        data-empty={pic ? undefined : ""}
        data-open={peek && !disabled ? "" : undefined}
        onPointerDown={down}
        onPointerUp={up}
        onPointerCancel={up}
        onPointerLeave={up}
        style={
          {
            "--iph-h": `${h}px`,
            "--iph-s": `${s}px`,
            "--iph-i": `${i}px`,
            "--iph-r": `${r}px`,
            "--iph-sr": `${sr}px`,
            "--iph-pl": `${side === "right" ? far : near}px`,
            "--iph-pr": `${side === "right" ? near : far}px`,
            ...(textColor ? { "--iph-text": textColor } : null),
            ...(fillColor ? { "--iph-fill": fillColor } : null),
            ...(fillTextColor ? { "--iph-fill-text": fillTextColor } : null),
            ...style,
          } as CSSProperties
        }
        {...rest}
      >
        {!fill && pic ? (
          <span className="iph-frost" aria-hidden="true">
            <img src={pic} alt="" decoding="async" draggable={false} onError={onError} />
          </span>
        ) : null}

        {fill ? <span className="iph-label">{children}</span> : null}

        <span className="iph-open" aria-hidden="true">
          {fill ? (
            <>
              <span className="iph-fill" />
              <span className="iph-label">{children}</span>
            </>
          ) : pic ? (
            <>
              <img className="iph-pic" src={pic} alt="" decoding="async" draggable={false} onError={onError} />
              <span className="iph-scrim" />
            </>
          ) : (
            <span className="iph-empty" />
          )}
        </span>

        <span className="iph-slot" aria-hidden="true">
          {fill ? (
            pic ? (
              <img src={pic} alt="" decoding="async" draggable={false} onError={onError} />
            ) : (
              <span className="iph-empty" />
            )
          ) : null}
          {icon ? <span className="iph-icon">{icon}</span> : null}
        </span>

        {!fill ? <span className="iph-label">{children}</span> : null}
      </button>
    </>
  );
});
```

Usage

Use it like any button. Only the picture is needed.

"use client";
import { PeepholeButton } from "@/components/ui/peephole-button";

export function TalkToUs() {
  return (
    <PeepholeButton
      variant="fill"                   // optional: "reveal" (default) or "fill"
      image="/team/ava.jpg"            // the picture: the whole image, or an avatar or logo
      shape="circle"                   // optional: "circle" (default) or "square"
      side="right"                     // optional: "left" (default) or "right"
      slotSize={32}                    // optional: the slot in px, 20 to 80
      fillColor="var(--primary)"       // optional, fill only: the color that pours in
      onClick={() => openChat()}
    >
      Talk to Ava
    </PeepholeButton>
  );
}

Everything happens inside the button, so it needs no extra room around it. Pictures look best when they are at least twice the button's size.

How it moves

At rest the slot is a small window in the glass. On hover it stretches open from where it sits until it fills the whole button.

In reveal, the glass is a heavily blurred copy of your picture, so it always takes the picture's colors, and the slot shows the same picture sharp. On hover the window widens across the button in 560ms with a soft ease out, the picture settles from a slight zoom to its real size, and a light shade fades in so the label stays easy to read. In fill, the glass is clear and your avatar stays in the slot. On hover the brand color pours out of the slot the same way, and the label turns white exactly where the color has reached. Moving away closes it in 420ms. On a phone, pressing opens it and it closes a moment after you lift your finger. Keyboard focus opens it too. With reduced motion, it switches open and closed without the stretch.

Props

PropDefaultWhat it does
children—The label. It stays on one line and trims with … if it runs out of room. Leave it out for a round button that is only the slot, and give it an aria-label.
image—The picture, any image URL. In "reveal" it is the whole picture (it also tints the glass). In "fill" it is the avatar or logo in the slot. If it is missing or fails to load, the button shows plain glass and an empty slot.
variant"reveal""reveal" opens the whole picture on hover. "fill" pours fillColor out of the slot on hover.
shape"circle""circle" is a round slot in a pill. "square" is a rounded square slot in a rounded button.
side"left"Which end the slot sits at.
slotSize32The slot in px, from 20 to 80. The button is 44px tall and grows to keep 6px around a bigger slot.
radius12Only with shape="square": the button's corner radius in px. The slot's corners are this radius minus the space around the slot, so the two always nest.
icon—A small icon shown in the middle of the slot, over the picture. It is drawn in white.
fillColorvioletOnly with variant="fill": the color that pours in. Any CSS color, including var(--…).
fillTextColorwhiteOnly with variant="fill": the label color where the fill has reached.
textColorwhite / themeThe label at rest. White in "reveal"; black in light mode and white in dark mode in "fill".
onClick, type, disabled, …type="button"Everything a normal button takes. Disabled keeps the slot closed.
className / style—On the button itself. Its width follows the label.