Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Lens

ProNew

A magnifying glass that follows the pointer over any content.

Installation

pnpm dlx shadcn@latest add @viewport/lens

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
zoomnumber

Magnification inside the lens.

1.8
sizenumber

Lens diameter in pixels.

170
children*React.ReactNode

What to magnify. It is rendered twice, so keep it free of ids and form state.

—
classNamestring—

Accessibility

  • The magnified copy is inert and hidden from assistive tech.
  • The content underneath stays fully interactive.
  • Position is written to CSS variables, so moving the lens never re-renders.