Aspect Crop, animated React component
- Pro
- Inputs & Controls
- Spring
An aspect-ratio picker whose crop frame keeps the same area at every ratio, so switching reads as re-cropping the same photo. The frame springs to its new shape and rule-of-thirds lines flash while it moves.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| ratios | AspectRatioOption[] | DEFAULT_ASPECT_RATIOS | Ratios to offer, each { id, w, h } (4:3, 1:1, 3:4 and 9:16 by default). |
| src | string | — | Photo to crop. Without it a drawn sunset illustration is shown. |
| alt | string | "" | Alt text for src. |
| onChange | (id: string) => void | — | Called with the ratio id when the user picks one. |
| autoplay | boolean | false | Cycles through the ratios until someone touches it. |
| size | number | 220 | Side of the square whose area every crop keeps, in px (100 to 280). A bigger number gives a bigger frame at every ratio. |
| radius | number | 18 | Corner radius of the frame, in px (0 to 60). |
| guides | "flash" | "always" | "off" | "flash" | When the thirds grid shows: flash while the frame moves, always, or off. |
| speed | number | 1 | How quickly the frame springs to its new shape (0.3 to 3). Higher is snappier. |
| bounce | number | 1 | How much the frame overshoots before it settles (0.4 to 2.5). Higher bounces more, lower settles dead. |
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
Aspect Crop 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 Aspect Crop works
Crop control that keeps the picture's area constant, so switching ratio reads as re-cropping the same photo rather than resizing it. The frame springs to its new shape, the photo stays put underneath, and thirds grid lines flash while it moves.
The source, the install command and the build prompt come with Pro.

