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
| Prop | Type | Default | What it does |
|---|---|---|---|
| theme | "auto" | "light" | "dark" | "auto" | "auto" follows the page's .dark class; "light" or "dark" pins the card's palette. |
| colors | string[] | ["#0071e3", "#64d2ff", "#bf5af2"] | Fill for the Direct, Search and Referral slices, bottom to top. |
| radius | number | 2 | Corner radius of each slice, in SVG units. |
| stagger | number | 12 | Delay between neighbouring days when the slices regroup, in ms. |
| autoplay | boolean | false | Scrubs along the columns and flips Day/Week until someone interacts. |
Add it to your project
- 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 createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 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:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand 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}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
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.

