Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Liquid Gauge, animated React component

  • Pro
  • Dashboards
  • Hover
  • Spring

A storage meter drawn as liquid in a glass orb, with two rolling wave layers, rising bubbles and a surface that leans toward the pointer. The percentage is drawn twice so the part under the liquid turns white, and changing the level sloshes it.

Props

PropTypeDefaultWhat it does
total200Capacity of the store, in units.
defaultUsed136Amount used on first render, clamped to 0..total.
accent"#0a84ff"Liquid colour while usage is below warnAt.
warnAt85Percentage at which the liquid turns orange and the caption warns.
unit"GB"Unit shown in the caption.
onChange—Called with the new amount after Clean up (-40) or Add files (+30).
autoplayfalseSloshes through a few fill levels until someone presses a button.

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

    Liquid Gauge 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 Liquid Gauge works

Storage shown as liquid in a glass orb. Two layers of waves roll at different speeds, bubbles rise, the surface leans toward the pointer, and the percentage is drawn twice so the part under the liquid turns white. Changing the level sloshes it.

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

Liquid Gauge questions

How do I install the Liquid Gauge?

Run `npx shadcn@latest add @nexus-labs/liquid-gauge`. It installs framer-motion and nothing else; the orb, waves and bubbles are drawn with SVG. 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 set the capacity, starting level and warning threshold?

`total` is the capacity (default 200), `defaultUsed` is the starting amount (default 136, clamped to 0..`total`), `warnAt` is the percentage where the liquid turns orange (default 85), and `unit` is the caption label (default "GB"). `accent` sets the liquid color below the threshold (default `#0a84ff`).

How do I connect it to real usage data?

`defaultUsed` is only read on the first render, so a later change to it will not move the liquid; remount the gauge with a changing `key` or edit the source to drive it from state. The built-in Clean up (-40) and Add files (+30) buttons call `onChange` with the new amount, but only when the amount actually changes.

How is the liquid animated, and does it respect reduced motion?

Two wave paths are rebuilt every frame with requestAnimationFrame and written straight to the SVG, while the level moves on a Framer Motion spring. With prefers-reduced-motion on, the waves stop rolling, the bubbles are not rendered and the slosh on a level change is skipped. The orb has `role="img"` with a "Storage N% used" label, and the caption is an `aria-live` region.