Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Spend Donut, animated React component

  • Pro
  • Dashboards
  • Hover
  • Spring

Spend Donut

A monthly budget donut: the slice you point at slides out of the ring and thickens while the centre rolls to its amount. Switch month and every slice re-measures itself in one continuous spring sweep. Also includes Spend Ring, a month of spending as a ring: point at a category and its arc swells, click it and the arc unwinds into a straight budget bar.

Spend Ring

Props

PropTypeDefaultWhat it does
thickness18Ring thickness in px (220px viewBox). The pointed-at slice grows by 6.
gap4Clear space between slices in px; the round caps are accounted for.
autoplayfalsePoints at each category in turn and changes month every ~8s until someone interacts.
SpendRing.title"Spending"Heading above the ring.
SpendRing.monthNamesMONTHSmonth names, oldest first; each category's `months` lines up with these
SpendRing.categoriesDEFAULT_CATEGORIESThe slices of the ring, each as { id, label, color, budget, months, txns }.
SpendRing.currency"$"Currency symbol shown before amounts.
SpendRing.onSelect—Called with the chosen category, or null when the selection is cleared.
SpendRing.enableSoundtrueSoft synthesised sounds as you use it. They also follow the site-wide sound switch.
SpendRing.volume0.6Sound level, 0 to 1.
SpendRing.autoplayfalsePlays a short demo by itself until the visitor touches it. Never runs under reduced motion.
SpendRing.className""Extra classes for the outer element.

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

    Spend Donut 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 Spend Donut works

A monthly budget as a donut. Point at a slice (or its row, or arrow through the rows) and it slides out from the ring and thickens while the centre rolls to that category. Change month and every slice re-measures itself in one continuous sweep instead of jumping.

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

Spend Donut questions

How do I install Spend Donut?

Run `npx shadcn@latest add @nexus-labs/spend-donut`. It adds the component and installs framer-motion. 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 pass my own categories and amounts?

Not through props. The five categories and the Aug, Sep and Oct figures are the `CATS` and `MONTHS` constants at the top of the file, and the "of $4,000 budget" label is fixed text, so edit those to show your own numbers.

Which props change the ring?

`thickness` sets the ring width in px (default 18) and the slice you point at grows by 6. `gap` sets the space between slices in px (default 4). `autoplay` is off by default and stops as soon as someone interacts.

Can I use it with the keyboard?

Yes. Each category row is a button: focusing it highlights its slice, and Arrow keys, Home and End move between rows. A live region announces the amount, and the component follows the visitor's reduced-motion setting through Framer Motion's `MotionConfig`.