Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Usage Stack, animated React component

  • Pro
  • Pricing Sections
  • Spring

Usage-based pricing you can see: every 10,000 requests is a block that drops into a bin, coloured by the tier it falls in. Slide the volume up and blocks rain in, slide it down and the newest pop, while the monthly price rolls with it and the blocks can be grabbed and thrown.

Props

PropTypeDefaultWhat it does
defaultValue120000Requests per month to start from, rounded to the nearest 10,000 (0 to 600,000).
onChange—Called whenever the volume changes, with the request count and the monthly price in dollars.
autoplayfalseSteps the volume through a few sample values every 2.6s until someone touches the slider or the bin. Off when reduced motion is preferred.

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

    Usage Stack 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 Usage Stack works

The default graduated pricing: free up to 50k, then $0.25 per 1k to 250k, then $0.15 per 1k.

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

Usage Stack questions

How do I install Usage Stack?

Run `npx shadcn@latest add @nexus-labs/usage-stack`. It adds the component and installs framer-motion and matter-js. 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).

Can I change the pricing tiers?

Not through props. Tiers come from the exported `USAGE_TIERS` array (Free up to 50,000 requests, Growth at $0.25 per 1,000 up to 250,000, then Scale at $0.15 per 1,000). Edit it; `usagePrice(n)` is exported too. The "First 50k are free" label is fixed text.

How do I set the starting volume and read changes?

`defaultValue` is the starting requests per month (default 120000), rounded to the nearest 10,000 and kept between 0 and 600,000. `onChange(requests, price)` fires whenever the volume changes, with the monthly price in dollars.

Which keys control the slider?

The slider is focusable. Arrow keys change the volume by 10,000 requests, PageUp and PageDown by 50,000, and Home and End jump to 0 and 600,000. Its `aria-valuetext` reads the requests, tier and monthly price.

How are the blocks simulated?

matter-js runs the physics, and each block is a DOM element moved with a CSS transform. The simulation pauses when the bin is off screen or the tab is hidden. `autoplay` is off by default and does not run when reduced motion is preferred.