Skip to content
caliper ui docs

Pro

Reveal lens

Two layers in one frame and a round lens that shows the second through the first. The lens trails the pointer on a spring, opens wider while pressed and closes when the pointer leaves.

Pro
pnpm dlx shadcn@latest add @caliper/reveal-lens

Print and photograph

Move over the print, or press to widen the lens.

The harbour at dusk, photographed
Installs components/ui/reveal-lens.tsxDepends on none beyond ReactMotion honours reduced motion

When to use

Use it for

  • Before and after, sketch and finish, wireframe and screen, print and photograph.
  • Explaining what a filter, model or edit changed.

Skip it when

  • Comparisons people need to measure; use the image compare slider.
  • Layers that differ in size or framing.

Decisions

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

Behaviour

Opens where it is aimed
A closed lens appears at the pointer instead of sliding in from where it last was.
Keyboard lens
Focus opens the lens in the middle and arrow keys move it; both layers are real content and both are read.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/reveal-lens

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

Usage

Import it from your copy of the source. The example behind the preview comes with the source.

example.tsx
import { RevealLens } from "@/components/ui/reveal-lens"

The worked example comes with Pro

The 26-line example behind the preview opens here, ready to copy.

  • 576 Pro parts, blocks and page templates, all with source
  • $199 once, with a year of updates. What you have stays yours
  • A full refund within 14 days if it is not for you
Checking your licence…

API reference

RevealLens

component

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

PropTypeDefaultDescription
reveal *ReactNode—The layer the lens shows: the photograph under the sketch, the finished screen under the wireframe.
label *string—Names the pair for assistive technology, e.g. "Wireframe and finished screen". Both layers are read.
radiusnumber88Lens radius in px; pressing opens it half again as wide.

Accessibility

It exposes group semantics, with aria-label and aria-hidden kept in step with state.

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

Motion

It checks prefers-reduced-motion itself and settles immediately instead of travelling. Every state is still reachable.

All Media examples