Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Traffic Bars, animated React component

  • Pro
  • Dashboards
  • Hover
  • Spring

A stacked bar chart of daily visits by source: the column under your pointer is ringed, the others dim and a tooltip glides beside it with the breakdown. Switch Day to Week and every day's slices fly over and pile into their week.

Props

PropTypeDefaultWhat it does
theme"auto""auto" follows the page's .dark class; "light" or "dark" pins the card's palette.
colors["#0071e3", "#64d2ff", "#bf5af2"]Fill for the Direct, Search and Referral slices, bottom to top.
radius2Corner radius of each slice, in SVG units.
stagger12Delay between neighbouring days when the slices regroup, in ms.
autoplayfalseScrubs along the columns and flips Day/Week until someone interacts.

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

    Traffic Bars 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 Traffic Bars works

Stacked traffic bars you can run your pointer along. The column under you is ringed, the rest dim, and a tooltip glides beside it. Switch Day to Week and every day's slices fly over and pile up into their week, so you can see where each total came from.

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

Traffic Bars questions

How do I install Traffic Bars?

Run `npx shadcn@latest add @nexus-labs/traffic-bars`. 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 feed it my own traffic data?

Not through props. The 28 days of Direct, Search and Referral numbers come from the `makeData` function in the file, and Week mode groups them into four weeks. Edit that function to use your own figures.

Which props change the colors and motion?

`colors` takes three fills for Direct, Search and Referral (default `#0071e3`, `#64d2ff`, `#bf5af2`). `radius` rounds each slice (default 2), `stagger` is the delay between days when slices regroup (default 12 ms), and `theme` is "auto", "light" or "dark".

Can I explore the chart with the keyboard?

Yes. Focus the chart and use the arrow keys to move between columns, Home and End to jump to the first or last, and Escape to clear. A live region reads out each column, and a hidden table lists the values.

Does it use a chart library?

No. The bars are SVG rects animated with Framer Motion springs, and framer-motion is the only dependency. Switching Day to Week moves each day's slices into their week's column.