Glass Lens, animated React component
- Pro
- Motion Effects
- Spring
Glass Lens
A glass puck you drag over content. It magnifies the centre and splits colour toward the rim, built from three offset copies of the content instead of a shader. Also includes Zoom Lens: A magnifier that springs after your pointer and shows full detail, so tiny map labels become readable. Scroll or use the slider to zoom.
Zoom Lens
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| size | number | 150 | Lens diameter in px. |
| zoom | number | 1.45 | Magnification at the centre of the lens. |
| width | number | 520 | Width of the content surface in px. |
| height | number | 300 | Height of the content surface in px. |
| children | ReactNode | Field notes text | Content under the glass. It is rendered four times (page plus three lens layers), so keep it static. |
| autoplay | boolean | false | Drifts across the content by itself until the user drags it. |
| ZoomLens.image | string | — | Zoom Lens: picture to magnify, as a URL or data URI. Defaults to a drawn map of an invented harbour district with tiny street names. |
| ZoomLens.darkImage | string | — | Zoom Lens: picture to use in dark mode. Defaults to a dark version of the demo map, or to image when you pass your own. |
| ZoomLens.aspectRatio | number | 1800 / 1100 | Zoom Lens: width divided by height of the picture. |
| ZoomLens.label | string | "Map of the harbour district. Use the lens to read street names." | Zoom Lens: accessible description of the picture. |
| ZoomLens.defaultZoom | number | 2.6 | Zoom Lens: starting magnification. |
| ZoomLens.minZoom | number | 1.5 | Zoom Lens: smallest magnification. |
| ZoomLens.maxZoom | number | 4 | Zoom Lens: largest magnification. |
| ZoomLens.lensSize | number | 164 | Zoom Lens: lens diameter in px. |
| ZoomLens.showControl | boolean | true | Zoom Lens: shows the zoom slider under the picture. The wheel and the plus and minus keys still work without it. |
| ZoomLens.autoplay | boolean | false | Zoom Lens: the lens wanders over the picture until someone points at it or presses a key. Never runs under reduced motion. |
| ZoomLens.className | string | — | Zoom Lens: extra classes for the wrapper. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry with your API key
Glass Lens is a Pro item, so the CLI has to send your API key. Do this once per project:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand add this entry inside the outermost braces, next to"aliases". Leave{name}and${NEXUS_API_KEY}exactly as written; the CLI fills them in:"registries": { "@nexus-labs": { "url": "https://www.nexus-ui.com/api/registry/{name}", "headers": { "Authorization": "Bearer ${NEXUS_API_KEY}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
How Glass Lens works
A draggable glass puck. Three copies of the content sit inside it at slightly different magnifications, tinted red, green and blue, so colour fringes grow toward the rim the way chromatic aberration does in a real lens.
The source, the install command and the build prompt come with Pro.
Glass Lens questions
How do I install Glass Lens?
Run `npx shadcn@latest add @nexus-labs/glass-lens`. It adds both GlassLens and the ZoomLens variant and installs framer-motion. It is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).
How do I put my own content under the GlassLens?
Pass it as `children`; it fills a surface of `width` by `height` (defaults 520 by 300). `size` sets the lens diameter (default 150) and `zoom` the centre magnification (default 1.45). Children render four times, so keep them static.
How is the color fringe made without a shader?
The lens holds three copies of your content: one at `zoom`, one slightly larger tinted red, one slightly smaller tinted blue, blended together. Their gap grows toward the rim, which looks like chromatic aberration. There is no canvas or WebGL.
How do I magnify my own image with ZoomLens?
Pass `image` (a URL or data URI), `darkImage` for dark mode, and `aspectRatio` as width divided by height. Zoom starts at `defaultZoom` (2.6) within `minZoom` 1.5 and `maxZoom` 4; the wheel, slider and +/- keys change it.
Can I use it from the keyboard or with reduced motion?
Both lenses are focusable and move with the arrow keys; ZoomLens also zooms with plus and minus. Under reduced motion, ZoomLens follows the pointer directly, fades instead of scaling in, and its `autoplay` never runs.

