Interactive Answers

Iso Bars

Isometric stacked bars in two rows — the main volume behind, rework or failures in front.

2 variantsMIT

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://ui.tmih06.com/r/iso-bars.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { IsoBars } from "@/components/ui/iso-bars";

export function DailyTokens({ usage }: { usage: DailyUsage }) {
  return (
    <IsoBars
      title="Daily tokens"
      subtitle="Last 14 days"
      labels={usage.days} // "Oct 23" … "Nov 5"
      back={[
        { id: "input", label: "Input", values: usage.input },
        { id: "cached", label: "Cached", values: usage.cached },
        { id: "output", label: "Output", values: usage.output },
      ]}
      front={[
        { id: "failed", label: "Failed", values: usage.failed },
        { id: "retried", label: "Retried", values: usage.retried },
      ]}
      aside={{ value: "18.4M", caption: "tokens", flag: "failed 1.9%" }}
      onSelect={({ row, index }) => openDay(usage.days[index], row)}
    />
  );
}

Props

PropTypeDefaultDescription
labels*string[]—One label per period, drawn along the front edge of the floor.
back*IsoSeries[]—The main stack, drawn as the back row. Series stack upward in order.
frontIsoSeries[]—A smaller stack in front, e.g. rework or failures. Shares the back row's scale and defaults to warning and negative colors.
title*string—Header title.
subtitlestring—Secondary line under the title.
aside{ value: string; caption?: string; flag?: string; tone?: "warning" | "negative" }—Headline in the header. The flag sits under it in the tone color.
format(value: number) => string—Formats values in the tooltip and the table. Defaults to 1.2k.
onSelect(point: { row: "back" | "front"; index: number }) => void—Called when a prism is hovered, clicked or reached with the arrow keys.
stringsPartial<IsoBarsLabels>—Your own UI strings (tooltip total, screen-reader text), for translating. Right-to-left works under `dir="rtl"`; the floor still runs left to right.
classNamestring—Extra classes for the root element.
type IsoSeries = {
  id: string;
  label: string;
  values: number[]; // one per period
  color?: string;   // faces are shaded from it with color-mix
};