Interactive Answers
Iso Bars
Isometric stacked bars in two rows — the main volume behind, rework or failures in front.
3 variantsMIT
Preview
Installation
Copies the component into components/ui and installs its dependencies and theme tokens.
pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/iso-bars.jsonUsage
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)}
/>
);
}
// Pass null while the usage request is in flight; keep stale data and set
// loading when refetching.
export function UsageState({ query }: { query: UsageQuery }) {
return (
<IsoBars
title="Tokens by day"
labels={query.data?.labels ?? null}
back={query.data?.back ?? null}
front={query.data?.front ?? null}
loading={query.isRefetching}
skeleton={{ count: 14 }}
/>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| labels* | string[] | null | — | One label per period, drawn along the front edge of the floor. |
| back* | IsoSeries[] | null | — | The main stack, drawn as the back row. Series stack upward in order. |
| front | IsoSeries[] | null | — | A smaller stack in front, e.g. rework or failures. Shares the back row's scale and defaults to warning and negative colors. |
| loading | boolean | false | Force the fixed-footprint skeleton while refetching, even when stale usage data is available. |
| skeleton | { count?: number } | — | Loading footprint hint for the number of periods. Falls back to stale labels, then 10. |
| title* | string | — | Header title. |
| subtitle | string | — | Secondary line under the title. |
| aside | { value: string; caption?: string; flag?: string; tone?: "warning" | "negative" } | null | — | 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. |
| strings | Partial<IsoBarsLabels> | — | Your own UI strings (loading announcement, tooltip total, screen-reader text), for translating. Right-to-left works under `dir="rtl"`; the floor still runs left to right. |
| className | string | — | 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
};