Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Glass Bubbles, animated React component

  • Pro
  • Motion Effects
  • Hover
  • Spring

Four glass orbs hang on threads from the top of a panel. Sweep the pointer through them and they swing, knock into each other and spin their icons before settling back under their anchors.

Props

PropTypeDefaultWhat it does
size1Size of every orb, 0.6 to 1.3. Bigger orbs knock into each other sooner.
threadLength1Length of every thread, 0.5 to 1.3. Longer threads swing wider and slower.
gravity1How hard the orbs are pulled down, 0.2 to 3. Lower floats, higher snaps back faster.
drag1How quickly swinging dies away, 0.25 to 4. Lower keeps swinging, higher settles fast.
push1How hard the pointer shoves an orb, 0.2 to 3.
autoplayfalseNudges a random bubble every 2.6 seconds until someone moves the pointer through them (skipped with reduced motion).

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

    Glass Bubbles 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 Glass Bubbles works

Glass orbs hanging on threads. Push them with the pointer and they swing, knock into each other and spin, then settle back under their anchors. Simple verlet pendulums with circle collisions, rendered as DOM so the glass can use real CSS gradients and blur.

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

Glass Bubbles questions

How do I install Glass Bubbles?

Run `npx shadcn@latest add @nexus-labs/glass-bubbles`. It depends on framer-motion and no physics library. 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).

Which props change how the bubbles move?

`size` (0.6 to 1.3), `threadLength` (0.5 to 1.3), `gravity` (0.2 to 3), `drag` (0.25 to 4) and `push` (0.2 to 3) all default to 1, and values outside the range are clamped. Lower `drag` keeps them swinging longer, and `push` sets how hard the pointer shoves an orb.

Is this canvas, WebGL or a physics engine?

None of them. A requestAnimationFrame loop runs simple Verlet pendulums with circle collisions, and Framer Motion values move the orbs, which are DOM elements styled with CSS gradients and blur. The threads are SVG paths.

Does it work with the keyboard and reduced motion?

The stage is focusable, and the Left and Right arrow keys push every bubble sideways. With prefers-reduced-motion on, `autoplay` no longer nudges the bubbles, but pointer and arrow-key input still move them.