Skip to content
caliper ui docs

Components

Pin drop

A pin you drop on a surface. Click, tap or press Enter and the pin falls from above onto the spot, squashes on landing and sends out one ring. Arrow keys nudge a placed pin.

Free
pnpm dlx shadcn@latest add @caliper/pin-drop

Meeting point

Click the harbour to drop a pin.

No pin yet
Installs components/ui/pin-drop.tsxDepends on none beyond ReactMotion none in component source

When to use

Use it for

  • Choosing a location on a map, photo or floor plan.
  • Annotating an image with a single point.

Skip it when

  • Many pins; use `CommentPins`.
  • Pins that must snap to real places; pair it with a search.

Decisions

Why it is built this way, so you know what to keep when you change your copy.

Behaviour

Position in percent
The pin is stored as percentages of the surface, so it stays put when the surface resizes.

Usage

One button, keys to nudge
The surface is a single button; Enter drops a pin at the centre, and arrow keys move a placed pin. Each drop is announced.
Still under reduced motion
The pin appears in place with no fall and no ring.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/pin-drop

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. No account needed. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

This is the code behind the preview above.

example.tsx
import { useState, type ReactNode } from "react"
import { Button } from "@/components/ui/button"
import { PinDrop, type PinPoint } from "@/components/ui/pin-drop"

function Panel({ title, context, className = "max-w-md", children }: { title: string; context: string; className?: string; children: ReactNode }) {
  return (
    <section className={`grid w-full gap-5 rounded-overlay border border-border bg-background p-6 shadow-resting max-sm:p-4 ${className}`}>
      <div className="grid gap-1">
        <p className="font-medium">{title}</p>
        <p className="text-sm text-muted-foreground">{context}</p>
      </div>
      {children}
    </section>
  );
}

export function PinDropDemo() {
  const [pin, setPin] = useState<PinPoint | null>(null);
  return (
    <Panel title="Meeting point" context="Click the harbour to drop a pin." className="max-w-lg">
      <PinDrop pin={pin} onPinChange={setPin} label="Harbour map" className="rounded-control">
        <img src="/media/harbour.jpg" alt="" className="aspect-[16/10] w-full object-cover" />
      </PinDrop>
      <div className="flex items-center justify-between gap-3 text-sm text-muted-foreground">
        <span className="tabular-nums">{pin ? `${Math.round(pin.x)}% across, ${Math.round(pin.y)}% down` : "No pin yet"}</span>
        <Button variant="ghost" size="sm" disabled={!pin} onClick={() => setPin(null)}>
          Clear
        </Button>
      </div>
    </Panel>
  );
}

API reference

PinDrop

component

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
pinPinPoint | null—The pin as percentages of the area, or null for none.
defaultPinPinPoint | nullnull
onPinChange((pin: PinPoint) => void)—
labelstring"Map"Names the area for assistive technology, e.g. "Map".

Accessibility

It exposes status semantics, with aria-label and aria-hidden kept in step with state. Changes that matter are announced through a live region.

No custom key handling; Tab and the native activation keys do the work.

Motion

It declares no animation in its component source. Any transition comes from its stylesheet, which uses the duration tokens that collapse to instant under prefers-reduced-motion.

All Surfaces examples