Components
Gesture hint
A ghost finger that shows a gesture once, in place of a block of instructions. It plays the movement a few times over its parent with a caption, and leaves for good the moment the person touches the area.
pnpm dlx shadcn@latest add @caliper/gesture-hintWhen to use
Use it for
- First sight of a swipeable row, a draggable card or a tappable map.
- Touch-first screens where the gesture cannot be guessed.
Skip it when
- Replacing visible controls; a hidden gesture should also have a button.
- Repeating on every visit; remember with `onDismiss`.
Decisions
Why it is built this way, so you know what to keep when you change your copy.
Behaviour
- Gone on first touch
- Any pointer press or key in the parent removes it and calls
onDismissonce.
Usage
- Caption is the message
- The finger is decoration; the caption is real text, so the hint still reads when the movement does not play.
- Still under reduced motion
- The finger rests at the start of the movement with the caption beneath it.
Installation
pnpm dlx shadcn@latest add @caliper/gesture-hint
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.
import { useState, type ReactNode } from "react" import { Button } from "@/components/ui/button" import { GestureHint } from "@/components/ui/gesture-hint" 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 GestureHintDemo() { const [kind, setKind] = useState<"tap" | "swipe-left" | "swipe-up" | "drag">("swipe-left"); const [round, setRound] = useState(0); return ( <Panel title="Inbox row" context="The hint leaves when you touch the row."> <div className="relative grid h-44 content-start gap-1 overflow-hidden rounded-control border border-border bg-muted px-4 pt-4"> <p className="text-sm font-medium">Invoice 2041 is ready</p> <p className="text-sm text-muted-foreground">Forma, due on the 24th</p> <GestureHint key={`${kind}-${round}`} gesture={kind} plays={4} label={{ tap: "Tap to open", "swipe-left": "Swipe to archive", "swipe-up": "Swipe up for details", drag: "Drag to reorder" }[kind]} className="bg-[color-mix(in_oklab,var(--muted)_70%,transparent)]" /> </div> <div className="flex flex-wrap gap-2" role="group" aria-label="Gesture"> {(["tap", "swipe-left", "swipe-up", "drag"] as const).map((item) => ( <Button key={item} variant={kind === item ? "default" : "secondary"} size="sm" aria-pressed={kind === item} onClick={() => { setKind(item); setRound((value) => value + 1); }} > {item.replace("-", " ")} </Button> ))} </div> </Panel> ); }
API reference
GestureHint
component
Also accepts the native props of its root element and a ref.
Accessibility
It exposes note semantics, with aria-hidden kept in step with state.
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.
Related
- Product tourA guided tour that spotlights one real control at a time, with a card that finds the side with room, keeps your place when paused, resumes from a small chip, and says so when a control is not on screen. Coachmark is the one-off hint.
- Swipe actionsRow actions revealed by swiping, with a keyboard route to the same actions.
- Pull to refreshPull a list down to refresh it, with a button for everyone else.