Lens
ProNewA 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
| Prop | Type | Default |
|---|---|---|
| zoom | numberMagnification inside the lens. | 1.8 |
| size | numberLens diameter in pixels. | 170 |
| children* | React.ReactNodeWhat to magnify. It is rendered twice, so keep it free of ids and form state. | — |
| className | string | — |
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.