Interactive Answers
Mirror Strips
Rows of dot strips with two series mirrored around a line — compare rounds or weeks on one axis, with pinned columns and notes.
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/mirror-strips.jsonUsage
Pass your own data and wire the callbacks to your agent runtime.
import { MirrorStrips } from "@/components/ui/mirror-strips";
// A contract review: where each side edited, round by round.
export function RedlineRounds({ review }: { review: Review }) {
return (
<MirrorStrips
title="Edits by page"
subtitle={`${review.pages} pages · ${review.rounds.length} rounds`}
columns={review.pageLabels}
rows={review.rounds.map((r, i) => ({
id: r.id,
label: r.name,
sublabel: r.date,
up: r.theirEdits,
down: r.ourRedlines,
current: i === review.rounds.length - 1,
}))}
series={{ up: { label: "Their edits" }, down: { label: "Our redlines" } }}
marks={review.openClauses.map((c) => ({ column: c.page, label: c.ref, note: c.title }))}
/>
);
}
// Pass null while the comparison request is in flight; keep stale data and
// set loading when refetching.
export function ComparisonState({ query }: { query: ComparisonQuery }) {
return (
<MirrorStrips
title="Edits by page"
columns={query.data?.pageLabels ?? null}
rows={query.data?.rows ?? null}
loading={query.isRefetching}
skeleton={{ count: query.data?.rows.length ?? 4, columns: 42 }}
series={{ up: { label: "Their edits" }, down: { label: "Our redlines" } }}
/>
);
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| columns* | string[] | null | — | One label per column. Every few are drawn under the chart. |
| rows* | MirrorRow[] | null | — | Each row has one count per column above the line and one below. |
| series* | { up: { label; color? }; down: { label; color? } } | — | Names and colors for the two sides. Defaults to foreground above, brand below. |
| loading | boolean | false | Force the fixed-footprint skeleton while refetching, even when stale comparison data is available. |
| skeleton | { count?: number; columns?: number } | — | Loading footprint hints: row and column counts. Falls back to stale data, then representative defaults. |
| title* | string | — | Header title. |
| subtitle | string | — | Secondary line under the title. |
| marks | MirrorMark[] | null | — | Columns pinned with a label above the chart and a note in the tooltip. |
| onSelect | (column: number) => void | — | Called when a column is hovered or reached with the arrow keys. |
| labels | Partial<MirrorStripsLabels> | — | Your own UI strings (loading announcement, dot scale note, screen-reader hint), for translating. Right-to-left works under `dir="rtl"`; columns still run left to right. |
| locale | string | — | BCP 47 locale for row totals. Defaults to en-US. |
| className | string | — | Extra classes for the root element. |
type MirrorRow = {
id: string;
label: string;
sublabel?: string;
up: number[];
down: number[];
current?: boolean; // emphasized label and total
};
type MirrorMark = { column: number; label: string; note?: string };
// Stacks hold up to five dots each way; bigger counts switch to one dot per group.