Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Polaroid Develop, animated React component

  • Pro
  • Cards
  • Spring

An instant photo you develop by dragging and shaking it: the faster it moves, the quicker the grey haze clears and the colour comes through. It swings with the drag velocity, develops slowly on its own, and writes a handwritten caption once it is done.

Props

PropTypeDefaultWhat it does
src—Photo to develop. Without it the drawn scenes are shown.
alt""Alt text for src.
caption—Handwritten caption for src once developed. Drawn scenes carry their own.
scenesDEFAULT_POLAROID_SCENESDrawn scenes cycled by New photo, each { sky, sea, sun, land, caption }.
onDeveloped—Called when the photo finishes developing, with its caption (or alt).
autoplayfalseShakes the photo by itself and swaps to a new one until someone touches it.
sensitivity1How quickly a shake clears the haze. Higher develops with gentler shakes. Clamped to 0.3 to 4.
swing1How far the photo tilts as you move it. 0 keeps it level. Clamped to 0 to 2.
elasticity0.5How far the photo follows the pointer when you drag it past its limit. Clamped to 0.1 to 1.
selfDeveloptrueLets the photo develop slowly by itself, the way a real one does. Turn it off and only shaking develops it.
className—Extra classes for the root.

Add it to your project

  1. 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 creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry with your API key

    Polaroid Develop is a Pro item, so the CLI has to send your API key. Do this once per project:

    1. Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with nxs_ and is shown only once.
    2. In your project root, next to package.json, create a file named .env.local with this line, using your own key:
      NEXUS_API_KEY=nxs_your_key_here
    3. Open components.json and 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}"
          }
        }
      }

How Polaroid Develop works

An instant photo you develop by shaking. Grab it and shake: the faster you move it, the quicker the grey haze clears and the colour comes through. It swings on its own weight as you drag, and once it's developed a caption writes itself along the bottom.

The source, the install command and the build prompt come with Pro.

Polaroid Develop questions

How do I install Polaroid Develop?

Run `npx shadcn@latest add @nexus-labs/polaroid-develop`. It installs framer-motion. Polaroid Develop 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 develop my own photo?

Pass `src` and `alt`. Add `caption` to have it written by hand once developed; without it no caption appears. `onDeveloped` is called with the caption, or `alt` if there is none. Without `src`, drawn scenes are shown.

How do I change the built-in scenes?

Pass `scenes` as objects of `{ sky, sea, sun, land, caption }`, where `sky` is a pair of gradient colours. The New photo button steps to the next scene and restarts the developing.

How does shaking develop the photo, and can I use the keyboard?

The faster you drag, the faster the haze clears, and it also develops slowly on its own. Focus the photo and press Enter or Space to shake it. Under reduced motion, that key advances the development in steps instead.