# C category bar 3

> Budget allocation — spend so far as a marker

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/c-category-bar-3).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/c-category-bar-3
- Screenshot: https://shadcn.exchange/shot/cnippet/c-category-bar-3/light.png
- Registry item: https://ui.cnippet.dev/r/c-category-bar-3.json
- Categories: category bar
- Listed: 2026-10-27, source last changed 2026-10-27

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-category-bar-3.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/category-bar`, `@cnippet/chart-utils`

## Files

### `registry/default/chart-variants/c-category-bar-3.tsx`

```tsx
"use client";

import { CategoryBar } from "@/registry/default/charts/category-bar";
import { formatCurrency } from "@/registry/default/lib/chart-utils";

// Q4 marketing budget split; the marker shows spend so far.
const budget = [
  { name: "Paid search", value: 42000 },
  { name: "Events", value: 28000 },
  { name: "Content", value: 18000 },
  { name: "Sponsorships", value: 12000 },
];
const SPENT = 61500;

export default function BudgetAllocation() {
  return (
    <div className="w-full max-w-md rounded-lg border bg-card p-5">
      <div className="flex items-baseline justify-between">
        <span className="font-medium text-sm">Q4 marketing budget</span>
        <span className="text-muted-foreground text-sm tabular-nums">
          {formatCurrency(SPENT)} spent
        </span>
      </div>
      <CategoryBar
        className="mt-4"
        labels={budget.map((b) => b.name)}
        marker={SPENT}
        valueFormatter={(value) => formatCurrency(value)}
        values={budget.map((b) => b.value)}
      />
      <ul className="mt-3 flex flex-wrap gap-x-4 gap-y-1 text-muted-foreground text-xs">
        {budget.map((b, i) => (
          <li className="flex items-center gap-1.5" key={b.name}>
            <span
              aria-hidden="true"
              className="size-2 rounded-xs"
              style={{ backgroundColor: `var(--chart-${i + 1})` }}
            />
            {b.name}
          </li>
        ))}
      </ul>
    </div>
  );
}
```
