Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(storybook): design system docs: color, typography, layout, charts (#15500)

Trang Nguyen261b888a9330
diff --git a/web/.storybook/main.ts b/web/.storybook/main.ts
index f12a2ada21..30d3d872cf 100644
--- a/web/.storybook/main.ts
+++ b/web/.storybook/main.ts
@@ -19,6 +19,14 @@ const DESIGN_COMPONENT_STORIES = [
"Spinner/Spinner",
"Switch/Switch",
] as const;
+// Design-system reference pages that sit directly under Design (not
+// Design/Components): the token reference, one single-leaf page per element.
+const DESIGN_REFERENCE_STORIES = [
+ "ThemeTokens/Color",
+ "ThemeTokens/Typography",
+ "ThemeTokens/Layout",
+ "ThemeTokens/Charts",
+] as const;
/**
* This function is used to resolve the absolute path of a package.
@@ -48,12 +56,49 @@ const config: StorybookConfig = {
files: `${storyPath}.stories.${STORY_EXTENSIONS}`,
titlePrefix: "Design/Components",
})),
+ // Design-system reference pages shown directly under Design.
+ ...DESIGN_REFERENCE_STORIES.map((storyPath) => ({
+ directory: "../src/components/design-system",
+ files: `${storyPath}.stories.${STORY_EXTENSIONS}`,
+ titlePrefix: "Design",
+ })),
// All other component stories belong to the flat Playground by default.
+ // Outside components/design-system the exclusion is by path, so a generic
+ // basename like Charts.stories.tsx elsewhere still reaches the Playground;
+ // inside design-system the curated names are negated by basename, which is
+ // safe there because those files are exactly the curated ones. Disjoint
+ // globs because !(...) matches a single path segment — which also means
+ // `!(dir)/**` requires at least one leading segment, so files sitting
+ // directly in the entry's directory need their own `*.stories` entry
+ // (hence the depth-one entries below). Caveat: picomatch
+ // treats !(Name) as a prefix negation here, so a design-system story whose
+ // basename merely starts with a curated name (e.g. ColorPicker) would be
+ // skipped too; give such a story a non-colliding basename or its own entry.
{
directory: "../src",
- files: `**/!(${DESIGN_COMPONENT_STORIES.map((storyPath) =>
- basename(storyPath),
- ).join("|")}).stories.${STORY_EXTENSIONS}`,
+ files: `*.stories.${STORY_EXTENSIONS}`,
+ titlePrefix: "Playground",
+ },
+ {
+ directory: "../src",
+ files: `!(components)/**/*.stories.${STORY_EXTENSIONS}`,
+ titlePrefix: "Playground",
+ },
+ {
+ directory: "../src/components",
+ files: `*.stories.${STORY_EXTENSIONS}`,
+ titlePrefix: "Playground",
+ },
+ {
+ directory: "../src/components",
+ files: `!(design-system)/**/*.stories.${STORY_EXTENSIONS}`,
+ titlePrefix: "Playground",
+ },
+ {
+ directory: "../src/components/design-system",
+ files: `**/!(${[...DESIGN_COMPONENT_STORIES, ...DESIGN_REFERENCE_STORIES]
+ .map((storyPath) => basename(storyPath))
+ .join("|")}).stories.${STORY_EXTENSIONS}`,
titlePrefix: "Playground",
},
],
@@ -64,7 +109,7 @@ const config: StorybookConfig = {
getAbsolutePath("@storybook/addon-vitest"),
],
framework: getAbsolutePath("@storybook/nextjs-vite"),
- staticDirs: ["../public"],
+ staticDirs: ["../public", "./public"],
// Resolve `@langfuse/shared` to its TypeScript source, mirroring the app's
// own alias (next.config.mjs: webpack alias + turbopack.resolveAlias both map
// "@langfuse/shared" -> "./packages/shared/src"). The package's published
diff --git a/web/.storybook/manager-head.html b/web/.storybook/manager-head.html
new file mode 100644
index 0000000000..61e261f40b
--- /dev/null
+++ b/web/.storybook/manager-head.html
@@ -0,0 +1,18 @@
+<link rel="icon" type="image/svg+xml" href="./storybook-favicon.svg" />
+<link
+ rel="icon"
+ type="image/png"
+ sizes="64x64"
+ href="./storybook-favicon-64.png"
+/>
+<script>
+ // Storybook's template links ./favicon.ico first, and the app's LF
+ // favicon.ico shadows it via the ../public staticDir; Safari (no SVG
+ // favicon support) and often Chrome pick that ICO over the links above.
+ // Drop every icon link that is not ours so the indigo mark always wins.
+ document.addEventListener("DOMContentLoaded", function () {
+ document.querySelectorAll('link[rel*="icon"]').forEach(function (link) {
+ if (!link.href.includes("storybook-favicon")) link.remove();
+ });
+ });
+</script>
diff --git a/web/.storybook/public/storybook-favicon-64.png b/web/.storybook/public/storybook-favicon-64.png
new file mode 100644
index 0000000000..c794b7cd49
Binary files /dev/null and b/web/.storybook/public/storybook-favicon-64.png differ
diff --git a/web/.storybook/public/storybook-favicon.svg b/web/.storybook/public/storybook-favicon.svg
new file mode 100644
index 0000000000..27721ef6d1
--- /dev/null
+++ b/web/.storybook/public/storybook-favicon.svg
@@ -0,0 +1,8 @@
+<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
+<path d="M254.75 302.25L285.25 326.75C285.25 326.75 308.587 309.418 325.75 306.875C343.75 304.208 362.954 314.244 380.75 326.208C407.629 344.279 430.25 367.208 430.25 367.208L456.75 341.208C456.75 341.208 383.686 262.047 325.75 269.208C287.75 273.905 254.75 302.25 254.75 302.25Z" fill="#4F39F6"/>
+<path d="M80.25 151.286L55.25 178.786C55.25 178.786 124.902 243.786 179.75 243.786C204.75 243.786 239.419 224.201 269.25 198.757C286.25 184.257 305.25 167.786 324.25 167.786C337.021 167.786 353.866 174.551 369.75 192.316C369.75 192.316 380.003 186.168 386.25 181.75C391.74 177.868 399.896 171.25 399.896 171.25C377.047 146.864 343.998 129.038 324.25 130.786C292.25 130.79 269.25 150.711 240.75 173.75C212.25 196.789 200.25 206.286 179.75 206.286C145.25 206.286 80.25 151.286 80.25 151.286Z" fill="#A78BFA"/>
+<path d="M80.25 360.75L55.25 333.25C55.25 333.25 124.902 268.25 179.75 268.25C204.75 268.25 239.419 287.835 269.25 313.279C286.25 327.779 305.25 344.25 324.25 344.25C337.083 344.25 353.799 337.207 369.75 319.25C369.75 319.25 379.339 325.161 385.25 329.25C391.328 333.455 400.25 340.407 400.25 340.407C377.39 364.987 344.1 383.007 324.25 381.25C292.25 381.246 273.25 364.289 244.75 341.25C216.25 318.211 200.25 305.75 179.75 305.75C145.25 305.75 80.25 360.75 80.25 360.75Z" fill="#A78BFA"/>
+<path d="M406.25 213.25C399.745 217.746 389.25 224.25 389.25 224.25C389.25 224.25 395.25 237.25 395.25 254.75C395.25 272.25 389.75 287.25 389.75 287.25C389.75 287.25 399.172 293.135 405.25 297.25C411.564 301.525 421.25 308.75 421.25 308.75C421.25 308.75 432.75 284.75 432.75 254.75C432.75 224.75 421.25 202.25 421.25 202.25C421.25 202.25 412.226 209.12 406.25 213.25Z" fill="#A78BFA"/>
+<path d="M256.25 209.25L285.25 185.25C285.25 185.25 308.587 202.04 325.75 204.583C343.75 207.25 362.954 197.214 380.75 185.25C407.629 167.179 430.25 144.25 430.25 144.25L456.75 170.25C456.75 170.25 383.686 249.411 325.75 242.25C287.75 237.553 256.25 209.25 256.25 209.25Z" fill="#4F39F6"/>
+<path d="M186.255 130.25C223.755 130.25 255.25 162.25 255.25 162.25C255.25 162.25 246.487 169.155 240.75 173.75C234.775 178.536 225.25 186.25 225.25 186.25C225.25 186.25 208.755 168.75 186.255 168.75C177.028 168.75 165.039 174.292 152.255 185.25C142.391 193.705 132.129 204.216 125.255 217.25C119.31 228.52 116.068 241.802 115.755 255.75C115.361 273.269 121.571 291.634 131.755 306.25C138.58 316.046 146.726 323.418 155.255 329.75C166.323 337.968 177.865 343.75 186.255 343.75C195.217 343.75 203.274 340.635 209.255 337.75C218.755 332.25 226.25 325.75 226.25 325.75L255.75 350.25C255.75 350.25 243.75 362.25 227.255 371.25C216.595 376.507 202.895 381.75 186.255 381.75C169.626 381.75 150.315 372.915 132.255 359.25C120.579 350.416 109.135 339.948 100.255 327.25C85.7005 306.438 78.2004 281.118 78.2502 255.75C78.3008 230.065 86.5823 204.625 101.255 183.75C124.255 153.75 158.273 130.25 186.255 130.25Z" fill="#4F39F6"/>
+</svg>
diff --git a/web/src/components/design-system/ThemeTokens/Charts.stories.tsx b/web/src/components/design-system/ThemeTokens/Charts.stories.tsx
new file mode 100644
index 0000000000..541d84c065
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Charts.stories.tsx
@@ -0,0 +1,13 @@
+import preview from "../../../../.storybook/preview";
+import { Charts as ChartsPage } from "./Charts";
+
+const meta = preview.meta({
+ component: ChartsPage,
+ parameters: {
+ layout: "fullscreen",
+ },
+});
+
+// Named after the component so Storybook's single-story hoisting collapses
+// Design / Charts into one sidebar leaf.
+export const Charts = meta.story({});
diff --git a/web/src/components/design-system/ThemeTokens/Charts.tsx b/web/src/components/design-system/ThemeTokens/Charts.tsx
new file mode 100644
index 0000000000..b8979b3084
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Charts.tsx
@@ -0,0 +1,221 @@
+/**
+ * Storybook-only chart color reference (Design → Charts), modeled on Kumo's
+ * chart-colors docs: the color systems split up front (categorical series vs
+ * per-score base colors), a numbered palette strip per system, and a small
+ * real chart sample painting from the tokens.
+ *
+ * Every value is parsed at build time from `src/styles/globals.css` (see
+ * parseThemeTokens.ts), so the page cannot drift from the stylesheet.
+ * Samples repaint under the active Storybook theme (toolbar switcher).
+ */
+import {
+ PageHeader,
+ rootEntries,
+ type TokenContext,
+ type TokenEntry,
+ TokenRow,
+ TokenSection,
+ useTokenContexts,
+} from "./shared";
+
+const seriesEntries = rootEntries
+ .filter((entry) => /^--chart-\d+$/.test(entry.name))
+ .sort(
+ (a, b) =>
+ Number(/\d+/.exec(a.name)?.[0] ?? 0) -
+ Number(/\d+/.exec(b.name)?.[0] ?? 0),
+ );
+const gridEntry = rootEntries.find((entry) => entry.name === "--chart-grid");
+const scaleEntries = rootEntries
+ .filter((entry) => /^--color-\d+$/.test(entry.name))
+ .sort(
+ (a, b) =>
+ Number(/\d+/.exec(a.name)?.[0] ?? 0) -
+ Number(/\d+/.exec(b.name)?.[0] ?? 0),
+ );
+
+/** Numbered swatch strip (Kumo-style palette overview). */
+function PaletteStrip({
+ ctx,
+ entries,
+}: {
+ ctx: TokenContext;
+ entries: TokenEntry[];
+}) {
+ return (
+ <div className="flex flex-wrap gap-2">
+ {entries.map((entry) => (
+ <div key={entry.name} className="flex flex-col items-center gap-1">
+ <span
+ className="border-border-contrast h-8 w-12 rounded-sm border"
+ style={{ background: ctx.color(entry.name) }}
+ />
+ <code className="text-muted-foreground font-mono text-[9px]">
+ {/\d+/.exec(entry.name)?.[0]}
+ </code>
+ </div>
+ ))}
+ </div>
+ );
+}
+
+/** One grouped bar chart painting every categorical series token. */
+function SeriesBarsSample({ ctx }: { ctx: TokenContext }) {
+ const heights = [0.85, 0.6, 0.72, 0.45, 0.65, 0.35, 0.55, 0.25];
+ return (
+ <div
+ className="flex h-24 items-end gap-2 rounded-md border px-3 pt-3"
+ style={{
+ background: ctx.color("--card"),
+ borderBottomColor: ctx.color("--chart-grid"),
+ }}
+ >
+ {seriesEntries.map((entry, index) => (
+ <div
+ key={entry.name}
+ className="flex-1 rounded-t-sm"
+ style={{
+ height: `${(heights[index % heights.length] ?? 0.5) * 100}%`,
+ background: ctx.color(entry.name),
+ }}
+ />
+ ))}
+ </div>
+ );
+}
+
+/** Per-token mini bars for the series rows. */
+function ChartBarSample({ ctx, name }: { ctx: TokenContext; name: string }) {
+ const index = Number(/\d+/.exec(name)?.[0] ?? 1);
+ return (
+ <div
+ className="flex h-10 items-end gap-1 rounded-md border px-2.5 pt-1.5"
+ style={{
+ background: ctx.color("--background"),
+ borderBottomColor: ctx.color("--chart-grid"),
+ }}
+ >
+ {[0.9, 0.55, 0.75, 0.4].map((height, barIndex) => (
+ <div
+ key={barIndex}
+ className="w-3 rounded-t-sm"
+ style={{
+ height: `${height * (0.6 + ((index * 7) % 5) / 10) * 100}%`,
+ background: ctx.color(name),
+ opacity: barIndex === 0 ? 1 : 0.75,
+ }}
+ />
+ ))}
+ </div>
+ );
+}
+
+function GridLinesSample({ ctx }: { ctx: TokenContext }) {
+ return (
+ <div
+ className="flex h-10 flex-col justify-between rounded-md border px-2.5 py-1.5"
+ style={{ background: ctx.color("--card") }}
+ >
+ {[0, 1, 2].map((line) => (
+ <div
+ key={line}
+ style={{ borderTop: `1px solid ${ctx.color("--chart-grid")}` }}
+ />
+ ))}
+ </div>
+ );
+}
+
+export function Charts() {
+ const { ctx, lightCtx, darkCtx } = useTokenContexts();
+
+ const rowProps = { ctx, lightCtx, darkCtx };
+
+ return (
+ <div className="p-6 md:p-10">
+ <div className="mx-auto flex w-full max-w-7xl flex-col gap-10">
+ <PageHeader
+ eyebrow="Design tokens"
+ title="Charts"
+ lede={
+ <>
+ Two palettes: categorical series colors, and per-score base
+ colors. Parsed at build time from{" "}
+ <code className="font-mono">src/styles/globals.css</code>.
+ </>
+ }
+ meta={
+ <>
+ {seriesEntries.length} series colors · {scaleEntries.length} score
+ base colors · 1 grid color
+ </>
+ }
+ />
+
+ <TokenSection
+ title="Categorical series"
+ blurb="One color per nominal series (trace name, model, level); more series than colors cycle with modulo."
+ count={seriesEntries.length}
+ sectionSample={
+ <div className="flex flex-col gap-3">
+ <PaletteStrip ctx={ctx} entries={seriesEntries} />
+ <SeriesBarsSample ctx={ctx} />
+ </div>
+ }
+ >
+ {seriesEntries.map((entry) => (
+ <TokenRow
+ key={entry.name}
+ name={entry.name}
+ entry={entry}
+ {...rowProps}
+ sample={<ChartBarSample ctx={ctx} name={entry.name} />}
+ />
+ ))}
+ </TokenSection>
+
+ <TokenSection
+ title="Score base colors"
+ blurb="One base color per score, not an ordered ramp. Heatmaps derive their lightness steps from a single base (score-analytics color-scales.ts); the runtime var() consumers are the rainbow and agent button gradients."
+ count={scaleEntries.length}
+ sectionSample={<PaletteStrip ctx={ctx} entries={scaleEntries} />}
+ >
+ {scaleEntries.map((entry) => (
+ <TokenRow
+ key={entry.name}
+ name={entry.name}
+ entry={entry}
+ {...rowProps}
+ sample={
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: ctx.color("--background") }}
+ >
+ <span
+ className="inline-block h-4 w-14 rounded-sm"
+ style={{ background: ctx.color(entry.name) }}
+ />
+ </div>
+ }
+ />
+ ))}
+ </TokenSection>
+
+ {gridEntry && (
+ <TokenSection
+ title="Grid"
+ blurb="Grid and axis lines; quiet so the series carry the contrast."
+ count={1}
+ >
+ <TokenRow
+ name={gridEntry.name}
+ entry={gridEntry}
+ {...rowProps}
+ sample={<GridLinesSample ctx={ctx} />}
+ />
+ </TokenSection>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/components/design-system/ThemeTokens/Color.stories.tsx b/web/src/components/design-system/ThemeTokens/Color.stories.tsx
new file mode 100644
index 0000000000..6fde1ce3df
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Color.stories.tsx
@@ -0,0 +1,13 @@
+import preview from "../../../../.storybook/preview";
+import { Color as ColorPage } from "./Color";
+
+const meta = preview.meta({
+ component: ColorPage,
+ parameters: {
+ layout: "fullscreen",
+ },
+});
+
+// Named after the component so Storybook's single-story hoisting collapses
+// Design / Color into one sidebar leaf.
+export const Color = meta.story({});
diff --git a/web/src/components/design-system/ThemeTokens/Color.tsx b/web/src/components/design-system/ThemeTokens/Color.tsx
new file mode 100644
index 0000000000..7a7f60a21d
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Color.tsx
@@ -0,0 +1,916 @@
+/**
+ * Storybook-only color reference (Design → Color), modeled on Carbon's color
+ * docs (interaction states) and Kumo's semantic-token tables (token rows
+ * grouped by role, purpose-first blurbs). The surface layering model lives on
+ * the Layout page.
+ *
+ * Every value is parsed at build time from `src/styles/globals.css` (see
+ * parseThemeTokens.ts), so the page cannot drift from the stylesheet. Dense
+ * rows show light and dark side by side with a compact live usage sample;
+ * samples repaint under the active Storybook theme (toolbar switcher).
+ */
+import { ChevronRight } from "lucide-react";
+import { type CSSProperties, type ReactNode } from "react";
+
+import {
+ CollapsedSection,
+ Eyebrow,
+ findTokenDeclaration,
+ InlineCode,
+ PageHeader,
+ pageForToken,
+ PageSection,
+ parsed,
+ rootEntries,
+ Swatch,
+ type TokenContext,
+ TokenRow,
+ TokenSection,
+ unassignedTokens,
+ useTokenContexts,
+} from "./shared";
+import { toCssColor } from "./parseThemeTokens";
+
+type SectionId =
+ | "surfaces"
+ | "fills"
+ | "borders"
+ | "brand"
+ | "controls"
+ | "mutedAccents"
+ | "status"
+ | "qlang"
+ | "sidebar"
+ | "findMatch"
+ | "other";
+
+/**
+ * First match wins; unmatched tokens land in "other" so new tokens always
+ * show up somewhere. Tokens other pages own are excluded up front via
+ * pageForToken (shared.tsx), the single source of page assignment.
+ */
+const SECTION_MATCHERS: Array<{
+ id: SectionId;
+ test: (name: string) => boolean;
+}> = [
+ {
+ id: "status",
+ test: (n) =>
+ /^--(?:accent-)?(?:light|dark)-(?:red|yellow|green|blue|violet|teal)$/.test(
+ n,
+ ),
+ },
+ {
+ id: "mutedAccents",
+ test: (n) => /^--muted-(?:magenta|blue|green|gray)$/.test(n),
+ },
+ { id: "qlang", test: (n) => n.startsWith("--qlang-") },
+ { id: "sidebar", test: (n) => n.startsWith("--sidebar-") },
+ { id: "findMatch", test: (n) => n.startsWith("--find-match-") },
+ { id: "controls", test: (n) => n.startsWith("--control-") },
+ {
+ id: "brand",
+ test: (n) => /^--(?:primary-accent|link|link-hover)$/.test(n),
+ },
+ {
+ id: "borders",
+ test: (n) => /^--(?:border|border-contrast|input|ring)$/.test(n),
+ },
+ {
+ id: "fills",
+ test: (n) =>
+ /^--(?:primary|secondary|tertiary|accent|destructive)(?:-foreground)?$/.test(
+ n,
+ ),
+ },
+ {
+ id: "surfaces",
+ test: (n) =>
+ /^--(?:background|foreground|foreground-tertiary|muted|surface-code(?:-header)?|popover|card|modal|header)(?:-foreground)?$/.test(
+ n,
+ ),
+ },
+];
+
+type SectionDef = { id: SectionId; title: string; blurb: string };
+
+/** High-traffic sections, always expanded. */
+const VISIBLE_SECTIONS: SectionDef[] = [
+ {
+ id: "surfaces",
+ title: "Surfaces & text tiers",
+ blurb:
+ "Canvas, elevation ladder and the paired text tiers that sit on them.",
+ },
+ {
+ id: "fills",
+ title: "Interactive fills",
+ blurb: "Button / hover / selection fills with their paired foregrounds.",
+ },
+ {
+ id: "borders",
+ title: "Borders & focus",
+ blurb: "Hairline, structure lines, input boundary and the focus ring.",
+ },
+ {
+ id: "brand",
+ title: "Brand & links",
+ blurb: "Accent for tabs/selection plus the hyperlink pair.",
+ },
+ {
+ id: "controls",
+ title: "Selection controls",
+ blurb: "Checkbox / switch fill, off-state track and unchecked boundary.",
+ },
+ {
+ id: "status",
+ title: "Status & accent pairs",
+ blurb:
+ "light-* tinted fills with dark-* readable text (chips, score levels).",
+ },
+ {
+ id: "mutedAccents",
+ title: "Muted accents",
+ blurb: "Observation-type accents and the chart-grid grey.",
+ },
+ {
+ id: "sidebar",
+ title: "Sidebar",
+ blurb: "Side navigation chrome, nav-item states and its hairline.",
+ },
+];
+
+/** Low-traffic sections, collapsed at the bottom. */
+const COLLAPSED_SECTIONS: SectionDef[] = [
+ {
+ id: "qlang",
+ title: "Query syntax highlighting",
+ blurb: "Search-bar grammar colors (field / value / number / keyword).",
+ },
+ {
+ id: "findMatch",
+ title: "Find match",
+ blurb: "In-page search highlight and the selected match.",
+ },
+ {
+ id: "other",
+ title: "Other",
+ blurb: "Tokens this page has no dedicated section for yet.",
+ },
+];
+
+/** `hsl(triplet / alpha)` for a token, for utility classes like bg-muted/50. */
+function alphaColor(ctx: TokenContext, name: string, alpha: number) {
+ const triplet = ctx.resolve(`var(${name})`);
+ return toCssColor(triplet)?.replace(/\)$/, ` / ${alpha})`);
+}
+
+/* ------------------------------------------------------------------------- *
+ * Interaction states (Carbon-style), grounded in the app's real classes.
+ * ------------------------------------------------------------------------- */
+
+function StateRow({
+ state,
+ sample,
+ classes,
+ tokens,
+ seenIn,
+}: {
+ state: string;
+ sample: ReactNode;
+ classes: string;
+ tokens: string;
+ seenIn: string;
+}) {
+ return (
+ <div className="grid items-center gap-x-8 gap-y-1 border-t py-3 md:grid-cols-[110px_minmax(0,1fr)_minmax(0,1.2fr)]">
+ <Eyebrow>{state}</Eyebrow>
+ <div className="min-w-0">{sample}</div>
+ <div className="text-muted-foreground flex min-w-0 flex-col gap-0.5 font-mono text-[10px] leading-4">
+ <span className="break-all">{classes}</span>
+ <span>tokens · {tokens}</span>
+ <span>as in · {seenIn}</span>
+ </div>
+ </div>
+ );
+}
+
+function InteractionStatesSection({ ctx }: { ctx: TokenContext }) {
+ const color = ctx.color;
+ const rowBase: CSSProperties = {
+ background: color("--background"),
+ color: color("--foreground"),
+ };
+ return (
+ <PageSection
+ title="Interaction states"
+ blurb="Hover, selected, active and focus, painted with the exact classes the app uses."
+ >
+ <div className="flex flex-col">
+ <StateRow
+ state="Hover · row"
+ classes="hover:bg-muted/50"
+ tokens="--muted at 50%"
+ seenIn="TableRow (ui/table.tsx)"
+ sample={
+ <div
+ className="flex flex-col rounded-md border text-xs"
+ style={rowBase}
+ >
+ <span className="border-b px-2.5 py-1.5">Default row</span>
+ <span
+ className="px-2.5 py-1.5"
+ style={{ background: alphaColor(ctx, "--muted", 0.5) }}
+ >
+ Hovered row
+ </span>
+ </div>
+ }
+ />
+ <StateRow
+ state="Selected · row"
+ classes="data-[state=selected]:bg-muted"
+ tokens="--muted"
+ seenIn="TableRow (ui/table.tsx)"
+ sample={
+ <div
+ className="flex flex-col rounded-md border text-xs"
+ style={rowBase}
+ >
+ <span className="border-b px-2.5 py-1.5">Default row</span>
+ <span
+ className="px-2.5 py-1.5"
+ style={{ background: color("--muted") }}
+ >
+ Selected row
+ </span>
+ </div>
+ }
+ />
+ <StateRow
+ state="Hover · item"
+ classes="focus:bg-accent focus:text-accent-foreground / hover:bg-accent"
+ tokens="--accent · --accent-foreground"
+ seenIn="DropdownMenuItem, ghost & outline Button"
+ sample={
+ <div
+ className="flex flex-col gap-0.5 rounded-md border p-1 text-xs"
+ style={{ background: color("--popover") }}
+ >
+ <span
+ className="rounded-sm px-2 py-1"
+ style={{ color: color("--popover-foreground") }}
+ >
+ Menu item
+ </span>
+ <span
+ className="rounded-sm px-2 py-1"
+ style={{
+ background: color("--accent"),
+ color: color("--accent-foreground"),
+ }}
+ >
+ Focused item
+ </span>
+ </div>
+ }
+ />
+ <StateRow
+ state="Active · tab"
+ classes="text-primary-accent + 2px underline"
+ tokens="--primary-accent"
+ seenIn="page-level tab bars"
+ sample={
+ <div
+ className="flex items-center gap-3 rounded-md border px-2.5 py-1.5 text-xs"
+ style={rowBase}
+ >
+ <span
+ className="pb-0.5 font-bold"
+ style={{
+ color: color("--primary-accent"),
+ boxShadow: `inset 0 -2px 0 ${color("--primary-accent")}`,
+ }}
+ >
+ Active tab
+ </span>
+ <span style={{ color: color("--muted-foreground") }}>
+ Other tab
+ </span>
+ </div>
+ }
+ />
+ <StateRow
+ state="Focus"
+ classes="focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
+ tokens="--ring · ring-offset uses --background"
+ seenIn="Button, Input, every focusable control"
+ sample={
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: color("--background") }}
+ >
+ <span
+ className="inline-block rounded-md border px-2.5 py-0.5 text-xs"
+ style={{
+ background: color("--card"),
+ color: color("--foreground"),
+ boxShadow: `0 0 0 2px ${color("--background")}, 0 0 0 4px ${color("--ring")}`,
+ }}
+ >
+ Focused
+ </span>
+ </div>
+ }
+ />
+ <StateRow
+ state="Disabled"
+ classes="disabled:opacity-50 disabled:cursor-not-allowed"
+ tokens="no dedicated token, opacity on the enabled colors"
+ seenIn="Button, Input"
+ sample={
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: color("--background") }}
+ >
+ <span
+ className="inline-block rounded-md px-2.5 py-0.5 text-xs opacity-50"
+ style={{
+ background: color("--primary"),
+ color: color("--primary-foreground"),
+ }}
+ >
+ Disabled button
+ </span>
+ </div>
+ }
+ />
+ </div>
+ </PageSection>
+ );
+}
+
+/* ------------------------------------------------------------------------- *
+ * Per-token usage samples (compact, one per row).
+ * ------------------------------------------------------------------------- */
+
+function SurfaceSample({
+ background,
+ color,
+ border,
+ children,
+}: {
+ background?: string;
+ color?: string;
+ border?: string;
+ children: string;
+}) {
+ return (
+ <div
+ className="truncate rounded-md border px-2.5 py-1.5 text-xs"
+ title={children}
+ style={{
+ background,
+ color,
+ ...(border ? { borderColor: border } : {}),
+ }}
+ >
+ {children}
+ </div>
+ );
+}
+
+function QuerySample({ ctx }: { ctx: TokenContext }) {
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5 font-mono text-xs"
+ style={{ background: ctx.color("--background") }}
+ >
+ <span style={{ color: ctx.color("--qlang-field") }}>level</span>
+ <span style={{ color: ctx.color("--muted-foreground") }}>:</span>
+ <span style={{ color: ctx.color("--qlang-value") }}>error</span>{" "}
+ <span style={{ color: ctx.color("--qlang-keyword") }}>AND</span>{" "}
+ <span style={{ color: ctx.color("--qlang-field") }}>latency</span>
+ <span style={{ color: ctx.color("--muted-foreground") }}>&gt;</span>
+ <span style={{ color: ctx.color("--qlang-number") }}>2000</span>
+ </div>
+ );
+}
+
+function FindMatchSample({ ctx }: { ctx: TokenContext }) {
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5 text-xs"
+ style={{
+ background: ctx.color("--background"),
+ color: ctx.color("--foreground"),
+ }}
+ >
+ the quick{" "}
+ <mark
+ style={{
+ background: ctx.color("--find-match-background"),
+ color: "inherit",
+ }}
+ >
+ brown
+ </mark>{" "}
+ fox,{" "}
+ <mark
+ style={{
+ background: ctx.color("--find-match-selected-background"),
+ color: ctx.color("--find-match-selected-foreground"),
+ }}
+ >
+ brown
+ </mark>{" "}
+ bear
+ </div>
+ );
+}
+
+function renderSample(
+ sectionId: SectionId,
+ name: string,
+ ctx: TokenContext,
+): ReactNode {
+ const color = ctx.color;
+ switch (sectionId) {
+ case "surfaces": {
+ const isText = name.includes("foreground");
+ if (isText) {
+ let base = name.replace(/-foreground$/, "");
+ if (name === "--foreground" || name === "--foreground-tertiary")
+ base = "--background";
+ if (name === "--muted-foreground") base = "--muted";
+ return (
+ <SurfaceSample background={color(base)} color={color(name)}>
+ Aa · The quick brown fox
+ </SurfaceSample>
+ );
+ }
+ const pairedText = ctx.decl(`${name}-foreground`)
+ ? `${name}-foreground`
+ : "--foreground";
+ return (
+ <SurfaceSample background={color(name)} color={color(pairedText)}>
+ {`Aa · text on ${name.slice(2)}`}
+ </SurfaceSample>
+ );
+ }
+ case "fills": {
+ const base = name.replace(/-foreground$/, "");
+ const fg = ctx.decl(`${base}-foreground`)
+ ? `${base}-foreground`
+ : "--foreground";
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: color("--background") }}
+ >
+ <span
+ className="inline-block rounded-md px-2.5 py-0.5 text-xs"
+ style={{ background: color(base), color: color(fg) }}
+ >
+ Button
+ </span>
+ </div>
+ );
+ }
+ case "borders": {
+ if (name === "--ring") {
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: color("--background") }}
+ >
+ <span
+ className="inline-block rounded-md border px-2.5 py-0.5 text-xs"
+ style={{
+ background: color("--card"),
+ color: color("--foreground"),
+ boxShadow: `0 0 0 2px ${color(name)}`,
+ }}
+ >
+ Focused
+ </span>
+ </div>
+ );
+ }
+ return (
+ <SurfaceSample
+ background={color("--card")}
+ color={color("--foreground")}
+ border={color(name)}
+ >
+ {`Aa · ${name.slice(2)} edge`}
+ </SurfaceSample>
+ );
+ }
+ case "brand": {
+ if (name === "--primary-accent") {
+ return (
+ <div
+ className="flex items-center gap-3 rounded-md border px-2.5 py-1.5 text-xs"
+ style={{
+ background: color("--background"),
+ color: color("--foreground"),
+ }}
+ >
+ <span
+ style={{
+ color: color(name),
+ boxShadow: `inset 0 -2px 0 ${color(name)}`,
+ }}
+ className="pb-0.5 font-bold"
+ >
+ Active tab
+ </span>
+ <span style={{ color: color("--muted-foreground") }}>
+ Other tab
+ </span>
+ </div>
+ );
+ }
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5 text-xs"
+ style={{ background: color("--background") }}
+ >
+ <span className="underline" style={{ color: color(name) }}>
+ {name === "--link-hover" ? "A hovered hyperlink" : "A hyperlink"}
+ </span>
+ </div>
+ );
+ }
+ case "controls": {
+ return (
+ <div
+ className="flex items-center gap-4 rounded-md border px-2.5 py-1.5"
+ style={{ background: color("--background") }}
+ >
+ {/* checked checkbox */}
+ <span
+ className="flex size-4 items-center justify-center rounded-sm text-[10px] font-bold"
+ style={{
+ background: color("--control-fill"),
+ color: color("--background"),
+ outline:
+ name === "--control-fill"
+ ? `2px solid ${color("--ring")}`
+ : undefined,
+ outlineOffset: 2,
+ }}
+ >
+ ✓
+ </span>
+ {/* unchecked checkbox */}
+ <span
+ className="size-4 rounded-sm border"
+ style={{
+ borderColor: color("--control-border"),
+ outline:
+ name === "--control-border"
+ ? `2px solid ${color("--ring")}`
+ : undefined,
+ outlineOffset: 2,
+ }}
+ />
+ {/* switch, off state */}
+ <span
+ className="flex h-4 w-8 items-center rounded-full px-0.5"
+ style={{
+ background: color("--control-track"),
+ outline:
+ name === "--control-track"
+ ? `2px solid ${color("--ring")}`
+ : undefined,
+ outlineOffset: 2,
+ }}
+ >
+ <span
+ className="size-3 rounded-full border"
+ style={{ background: color("--card") }}
+ />
+ </span>
+ </div>
+ );
+ }
+ case "mutedAccents": {
+ return (
+ <div
+ className="flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-xs"
+ style={{ background: color("--card") }}
+ >
+ <span
+ className="size-3.5 rounded-sm"
+ style={{ background: color(name) }}
+ />
+ <span style={{ color: color(name) }} className="font-bold">
+ Aa
+ </span>
+ <span
+ style={{ color: color("--muted-foreground") }}
+ className="text-[10px]"
+ >
+ span label
+ </span>
+ </div>
+ );
+ }
+ case "status": {
+ const match = /^--(accent-)?(?:light|dark)-(\w+)$/.exec(name);
+ const prefix = match?.[1] ?? "";
+ const hue = match?.[2] ?? "";
+ const fill = `--${prefix}light-${hue}`;
+ const text = `--${prefix}dark-${hue}`;
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: color("--background") }}
+ >
+ <span
+ className="inline-block rounded-sm px-2 py-0.5 text-xs font-bold"
+ style={{ background: color(fill), color: color(text) }}
+ >
+ {prefix ? `accent ${hue}` : hue} · 0.87
+ </span>
+ </div>
+ );
+ }
+ // Whole-section samples (all tokens paint the same demo) render once in
+ // the section header instead of repeating per row.
+ case "qlang":
+ case "findMatch":
+ return null;
+ case "sidebar": {
+ if (name === "--sidebar-ring") {
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: color("--sidebar-background") }}
+ >
+ <span
+ className="inline-block rounded-md px-2 py-0.5 text-xs"
+ style={{
+ color: color("--sidebar-foreground"),
+ boxShadow: `0 0 0 2px ${color(name)}`,
+ }}
+ >
+ Focused item
+ </span>
+ </div>
+ );
+ }
+ if (name === "--sidebar-border") {
+ return (
+ <SurfaceSample
+ background={color("--sidebar-background")}
+ color={color("--sidebar-foreground")}
+ border={color(name)}
+ >
+ Aa · sidebar hairline
+ </SurfaceSample>
+ );
+ }
+ const usesPrimary = name.startsWith("--sidebar-primary");
+ const usesAccent = name.startsWith("--sidebar-accent");
+ let itemStyle: CSSProperties = { color: color("--sidebar-foreground") };
+ let itemLabel = "Nav item";
+ if (usesPrimary) {
+ itemStyle = {
+ background: color("--sidebar-primary"),
+ color: color("--sidebar-primary-foreground"),
+ };
+ itemLabel = "Primary item";
+ } else if (usesAccent) {
+ itemStyle = {
+ background: color("--sidebar-accent"),
+ color: color("--sidebar-accent-foreground"),
+ };
+ itemLabel = "Hovered item";
+ }
+ return (
+ <div
+ className="flex items-center gap-1 rounded-md border p-1 text-xs"
+ style={{
+ background: color("--sidebar-background"),
+ borderColor: color("--sidebar-border"),
+ }}
+ >
+ <span
+ className="truncate rounded-md px-2 py-0.5"
+ title={itemLabel}
+ style={itemStyle}
+ >
+ {itemLabel}
+ </span>
+ <span
+ className="truncate px-2 py-0.5"
+ title="Another item"
+ style={{ color: color("--sidebar-foreground") }}
+ >
+ Another item
+ </span>
+ </div>
+ );
+ }
+ case "other":
+ default: {
+ const swatchColor = color(name);
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5 font-mono text-[11px]"
+ style={{
+ background: color("--background"),
+ color: color("--foreground"),
+ }}
+ >
+ {swatchColor ? (
+ <span
+ className="inline-block h-4 w-14 rounded-sm"
+ style={{ background: swatchColor }}
+ />
+ ) : (
+ ctx.resolve(ctx.decl(name) ?? "") || "—"
+ )}
+ </div>
+ );
+ }
+ }
+}
+
+/** Section demos rendered once (their tokens all paint the same sample). */
+const SECTION_SAMPLES: Partial<
+ Record<SectionId, (ctx: TokenContext) => ReactNode>
+> = {
+ qlang: (ctx) => <QuerySample ctx={ctx} />,
+ findMatch: (ctx) => <FindMatchSample ctx={ctx} />,
+};
+
+/** Tailwind color mappings from @theme inline (collapsed, low traffic). */
+function ColorMappingsSection({ ctx }: { ctx: TokenContext }) {
+ const colorMappings = parsed.inlineTokens.filter(
+ (t) => t.name.startsWith("--color-") && t.value !== "initial",
+ );
+ const disabled = parsed.inlineTokens.filter((t) => t.value === "initial");
+
+ return (
+ <details className="group border-t pt-6">
+ <summary className="flex cursor-pointer list-none items-start gap-2 [&::-webkit-details-marker]:hidden">
+ <ChevronRight
+ aria-hidden
+ className="text-muted-foreground mt-1.5 size-4 shrink-0 transition-transform group-open:rotate-90"
+ />
+ <div className="flex flex-1 items-baseline justify-between gap-4">
+ <div>
+ <h2 className="text-foreground text-lg font-bold">
+ Tailwind color mappings
+ </h2>
+ <p className="text-muted-foreground max-w-2xl text-sm">
+ @theme inline: utility → token wiring plus the disabled built-in
+ palettes.
+ </p>
+ </div>
+ <InlineCode>{colorMappings.length} tokens</InlineCode>
+ </div>
+ </summary>
+ <div className="flex flex-col gap-6 pt-3 pl-6">
+ <div className="columns-1 gap-8 md:columns-2 xl:columns-3">
+ {colorMappings.map((token) => (
+ <div
+ key={token.name}
+ className="border-border flex items-center gap-2 border-b py-1 font-mono text-[11px] leading-4"
+ >
+ <Swatch color={toCssColor(ctx.resolve(token.value))} />
+ <code className="text-foreground shrink-0">{token.name}</code>
+ <span
+ className="text-muted-foreground truncate"
+ title={token.value}
+ >
+ {token.value}
+ </span>
+ </div>
+ ))}
+ </div>
+ {disabled.length > 0 && (
+ <p className="text-muted-foreground font-mono text-[11px]">
+ Disabled built-in palettes:{" "}
+ {disabled
+ .map((token) =>
+ token.name.replace("--color-", "").replace("-*", ""),
+ )
+ .join(", ")}
+ </p>
+ )}
+ </div>
+ </details>
+ );
+}
+
+export function Color() {
+ const { ctx, lightCtx, darkCtx } = useTokenContexts();
+
+ const sectionEntries = new Map<SectionId, typeof rootEntries>();
+ for (const entry of rootEntries) {
+ if (pageForToken(entry.name) !== "color") continue; // other pages own these
+ const matcher = SECTION_MATCHERS.find((m) => m.test(entry.name));
+ const section = matcher?.id ?? "other";
+ const bucket = sectionEntries.get(section) ?? [];
+ bucket.push(entry);
+ sectionEntries.set(section, bucket);
+ }
+
+ const colorEntryCount = [...sectionEntries.values()].reduce(
+ (total, bucket) => total + bucket.length,
+ 0,
+ );
+ const renderRows = (id: SectionId) =>
+ (sectionEntries.get(id) ?? []).map((entry) => (
+ <TokenRow
+ key={entry.name}
+ name={entry.name}
+ entry={entry}
+ ctx={ctx}
+ lightCtx={lightCtx}
+ darkCtx={darkCtx}
+ sample={renderSample(id, entry.name, ctx)}
+ />
+ ));
+
+ return (
+ <div className="p-6 md:p-10">
+ <div className="mx-auto flex w-full max-w-7xl flex-col gap-10">
+ <PageHeader
+ eyebrow="Design tokens"
+ title="Color"
+ lede={
+ <>
+ Parsed at build time from{" "}
+ <code className="font-mono">src/styles/globals.css</code>. The
+ toolbar switcher previews light/dark.
+ </>
+ }
+ meta={<>{colorEntryCount} color tokens · light and dark</>}
+ />
+ <InteractionStatesSection ctx={ctx} />
+ {VISIBLE_SECTIONS.map(({ id, title, blurb }) => {
+ const rows = renderRows(id);
+ if (rows.length === 0) return null;
+ return (
+ <TokenSection
+ key={id}
+ title={title}
+ blurb={blurb}
+ count={rows.length}
+ sectionSample={SECTION_SAMPLES[id]?.(ctx)}
+ >
+ {rows}
+ </TokenSection>
+ );
+ })}
+ <div className="flex flex-col gap-6">
+ {COLLAPSED_SECTIONS.map(({ id, title, blurb }) => {
+ const rows = renderRows(id);
+ if (rows.length === 0) return null;
+ return (
+ <CollapsedSection
+ key={id}
+ title={title}
+ blurb={blurb}
+ count={rows.length}
+ sectionSample={SECTION_SAMPLES[id]?.(ctx)}
+ >
+ {rows}
+ </CollapsedSection>
+ );
+ })}
+ <ColorMappingsSection ctx={ctx} />
+ {unassignedTokens.length > 0 && (
+ <CollapsedSection
+ title="Unassigned tokens"
+ blurb="Tokens no reference page claims yet (PAGE_TOKEN_MATCHERS in shared.tsx). Give each one a home."
+ count={unassignedTokens.length}
+ >
+ {unassignedTokens.map((name) => {
+ const { entry, staticDecl } = findTokenDeclaration(name);
+ return (
+ <TokenRow
+ key={name}
+ name={name}
+ entry={entry}
+ staticDecl={staticDecl}
+ ctx={ctx}
+ lightCtx={lightCtx}
+ darkCtx={darkCtx}
+ sample={null}
+ />
+ );
+ })}
+ </CollapsedSection>
+ )}
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/components/design-system/ThemeTokens/Layout.stories.tsx b/web/src/components/design-system/ThemeTokens/Layout.stories.tsx
new file mode 100644
index 0000000000..9225221356
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Layout.stories.tsx
@@ -0,0 +1,13 @@
+import preview from "../../../../.storybook/preview";
+import { Layout as LayoutPage } from "./Layout";
+
+const meta = preview.meta({
+ component: LayoutPage,
+ parameters: {
+ layout: "fullscreen",
+ },
+});
+
+// Named after the component so Storybook's single-story hoisting collapses
+// Design / Layout into one sidebar leaf.
+export const Layout = meta.story({});
diff --git a/web/src/components/design-system/ThemeTokens/Layout.tsx b/web/src/components/design-system/ThemeTokens/Layout.tsx
new file mode 100644
index 0000000000..5ad89144f6
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Layout.tsx
@@ -0,0 +1,429 @@
+/**
+ * Storybook-only layout reference (Design → Layout): the radius system, the
+ * banner offset system used by fixed/sticky positioning, the surface layering
+ * model, the app's overlay layer order, animation tokens, and the breakpoint
+ * conventions.
+ *
+ * Token values are parsed at build time from `src/styles/globals.css` (see
+ * parseThemeTokens.ts), so the page cannot drift from the stylesheet. The
+ * layer order is read from its source of truth, `components/ui/layer.tsx`.
+ *
+ * Every section is a standalone component on purpose, so it can fold into
+ * another reference page cheaply if this page is ever dissolved.
+ */
+import { type CSSProperties } from "react";
+
+import { LAYER_ORDER } from "@/src/components/ui/layer";
+
+import {
+ CollapsedSection,
+ Eyebrow,
+ InlineCode,
+ PageHeader,
+ PageSection,
+ parsed,
+ rootEntries,
+ type TokenContext,
+ TokenRow,
+ TokenSection,
+ useTokenContexts,
+} from "./shared";
+
+const radiusEntry = rootEntries.find((entry) => entry.name === "--radius");
+const inlineRadii = parsed.inlineTokens.filter((t) =>
+ /^--radius-/.test(t.name),
+);
+const bannerEntries = rootEntries.filter((entry) =>
+ entry.name.startsWith("--banner-"),
+);
+const spacingTokens = parsed.inlineTokens.filter((t) =>
+ t.name.startsWith("--spacing-"),
+);
+const animationTokens = parsed.inlineTokens.filter((t) =>
+ t.name.startsWith("--animate-"),
+);
+
+type RowContexts = {
+ ctx: TokenContext;
+ lightCtx: TokenContext;
+ darkCtx: TokenContext;
+};
+
+function RadiusSample({
+ ctx,
+ radius,
+}: {
+ ctx: TokenContext;
+ radius: string | undefined;
+}) {
+ return (
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: ctx.color("--background") }}
+ >
+ <div
+ className="h-7 w-16 border"
+ style={{
+ background: ctx.color("--muted"),
+ borderColor: ctx.color("--border-contrast"),
+ borderRadius: radius,
+ }}
+ />
+ </div>
+ );
+}
+
+/** The radius scale: one base token, derived sm / md / lg steps. */
+export function RadiiSection({ ctx, lightCtx, darkCtx }: RowContexts) {
+ const count = (radiusEntry ? 1 : 0) + inlineRadii.length;
+ return (
+ <TokenSection
+ title="Radii"
+ blurb="One base radius; the sm / md / lg steps derive from it."
+ count={count}
+ >
+ {radiusEntry && (
+ <TokenRow
+ name={radiusEntry.name}
+ entry={radiusEntry}
+ ctx={ctx}
+ lightCtx={lightCtx}
+ darkCtx={darkCtx}
+ sample={<RadiusSample ctx={ctx} radius={ctx.decl("--radius")} />}
+ />
+ )}
+ {inlineRadii.map((token) => (
+ <TokenRow
+ key={token.name}
+ name={token.name}
+ staticDecl={token}
+ ctx={ctx}
+ lightCtx={lightCtx}
+ darkCtx={darkCtx}
+ sample={<RadiusSample ctx={ctx} radius={ctx.resolve(token.value)} />}
+ />
+ ))}
+ </TokenSection>
+ );
+}
+
+/** Mini viewport: banner strip on top, app content filling the remainder. */
+function BannerSystemSample({ ctx }: { ctx: TokenContext }) {
+ return (
+ <div
+ className="flex h-36 w-full max-w-sm flex-col overflow-hidden rounded-md border"
+ style={{ background: ctx.color("--background") }}
+ >
+ <div
+ className="flex items-center justify-center border-b px-2 py-1"
+ style={{
+ background: ctx.color("--light-yellow"),
+ color: ctx.color("--dark-yellow"),
+ }}
+ >
+ <span className="font-mono text-[10px]">
+ banner · height = --banner-height
+ </span>
+ </div>
+ <div className="flex grow flex-col gap-1 p-2">
+ <span className="text-muted-foreground font-mono text-[10px]">
+ app content · height = --spacing-screen-with-banner
+ </span>
+ <span className="text-muted-foreground font-mono text-[10px]">
+ sticky/fixed elements offset by --banner-offset
+ </span>
+ <div
+ className="mt-1 grow rounded-sm border"
+ style={{ background: ctx.color("--card") }}
+ />
+ </div>
+ </div>
+ );
+}
+
+/** The banner offset system used by fixed/sticky positioning. */
+export function LayoutOffsetsSection({ ctx, lightCtx, darkCtx }: RowContexts) {
+ const count = bannerEntries.length + spacingTokens.length;
+ return (
+ <TokenSection
+ title="Layout offsets"
+ blurb="A banner raises --banner-height; everything below offsets by --banner-offset; full-height layouts use screen-with-banner, not 100svh."
+ count={count}
+ sectionSample={<BannerSystemSample ctx={ctx} />}
+ >
+ {bannerEntries.map((entry) => (
+ <TokenRow
+ key={entry.name}
+ name={entry.name}
+ entry={entry}
+ ctx={ctx}
+ lightCtx={lightCtx}
+ darkCtx={darkCtx}
+ sample={null}
+ />
+ ))}
+ {spacingTokens.map((token) => (
+ <TokenRow
+ key={token.name}
+ name={token.name}
+ staticDecl={token}
+ ctx={ctx}
+ lightCtx={lightCtx}
+ darkCtx={darkCtx}
+ sample={null}
+ />
+ ))}
+ </TokenSection>
+ );
+}
+
+/* ------------------------------------------------------------------------- *
+ * Layering model (Carbon-style): the surface ladder, both themes at once.
+ * ------------------------------------------------------------------------- */
+
+const LAYERS: Array<{ token: string; label: string }> = [
+ { token: "--background", label: "app canvas" },
+ { token: "--card", label: "elevated panel" },
+ { token: "--popover", label: "menus & tooltips" },
+ { token: "--modal", label: "dialogs" },
+];
+
+function LayerStack({
+ paint,
+ layers,
+}: {
+ paint: TokenContext;
+ layers: Array<{ token: string; label: string }>;
+}) {
+ const [head, ...rest] = layers;
+ if (!head) return null;
+ return (
+ <div
+ className="flex flex-col gap-2 rounded-md border p-3"
+ style={{
+ background: paint.color(head.token),
+ borderColor: paint.color("--border"),
+ }}
+ >
+ <code
+ className="font-mono text-[10px] leading-4"
+ style={{ color: paint.color("--muted-foreground") }}
+ >
+ {head.token} · {head.label}
+ </code>
+ {rest.length > 0 && <LayerStack paint={paint} layers={rest} />}
+ </div>
+ );
+}
+
+export function LayeringSection({
+ lightCtx,
+ darkCtx,
+}: {
+ lightCtx: TokenContext;
+ darkCtx: TokenContext;
+}) {
+ // Only show tiers the current stylesheet actually declares, so the demo
+ // stays truthful on branches where a surface token does not exist yet.
+ const layers = LAYERS.filter(
+ ({ token }) =>
+ lightCtx.decl(token) !== undefined || darkCtx.decl(token) !== undefined,
+ );
+ return (
+ <PageSection
+ title="Layering model"
+ blurb="Surfaces stack from the canvas outward. Use the tiers in order; skipping flattens the depth cues."
+ aside={<InlineCode>{layers.length} tiers</InlineCode>}
+ >
+ <div className="grid gap-4 lg:grid-cols-2">
+ {[
+ { label: "light", paint: lightCtx },
+ { label: "dark", paint: darkCtx },
+ ].map(({ label, paint }) => (
+ <div key={label} className="flex flex-col gap-1.5">
+ <Eyebrow>{label}</Eyebrow>
+ <LayerStack paint={paint} layers={layers} />
+ </div>
+ ))}
+ </div>
+ </PageSection>
+ );
+}
+
+/** Short, honest description per layer band (source: layer.tsx JSDoc). */
+const LAYER_DESCRIPTIONS: Record<string, string> = {
+ panel: "docked side surfaces: Sheet, Drawer, table peek",
+ agent: "the in-app assistant window, below every true overlay",
+ modal: "blocking Dialog and AlertDialog surfaces",
+ popover: "Popover, DropdownMenu, Select; above modal by design",
+ tooltip: "Tooltip and bespoke anchored tooltips",
+ toast: "Sonner toasts, always on top",
+};
+
+/**
+ * The app's overlay layer order, read from components/ui/layer.tsx. These are
+ * code constants mapped to DOM containers in _document.tsx, not CSS tokens:
+ * layers stack purely by DOM order.
+ */
+export function LayerSystemSection({ ctx }: { ctx: TokenContext }) {
+ return (
+ <PageSection
+ title="Overlay layers"
+ blurb="Overlays portal through layer containers, never raw z-index. Bands stack by DOM order."
+ aside={<InlineCode>{LAYER_ORDER.length} bands</InlineCode>}
+ >
+ <div
+ className="relative overflow-hidden rounded-md border p-4"
+ style={{
+ background: ctx.color("--background"),
+ height: `${LAYER_ORDER.length * 34 + 72}px`,
+ }}
+ >
+ {LAYER_ORDER.map((name, index) => (
+ <div
+ key={name}
+ className="absolute flex w-72 max-w-full items-baseline gap-2 rounded-md border px-3 py-2"
+ style={{
+ left: `${16 + index * 28}px`,
+ top: `${16 + index * 34}px`,
+ background: ctx.color("--card"),
+ color: ctx.color("--foreground"),
+ }}
+ >
+ <code className="font-mono text-[11px]">{name}</code>
+ <span
+ className="truncate text-[10px]"
+ title={LAYER_DESCRIPTIONS[name]}
+ style={{ color: ctx.color("--muted-foreground") }}
+ >
+ {LAYER_DESCRIPTIONS[name] ?? ""}
+ </span>
+ </div>
+ ))}
+ <span className="text-muted-foreground absolute right-3 bottom-2 font-mono text-[10px]">
+ later in LAYER_ORDER paints on top ↘
+ </span>
+ </div>
+ <p className="text-muted-foreground text-sm">
+ Source of truth: <InlineCode>LAYER_ORDER</InlineCode> in{" "}
+ <code className="font-mono">components/ui/layer.tsx</code>, enforced by
+ the <code className="font-mono">@repo/no-overlay-zindex</code> lint
+ rule.
+ </p>
+ </PageSection>
+ );
+}
+
+/**
+ * Per-token setup the animation needs to be visible: rainbow animates
+ * background-position (needs a >100% background-image), the accordion pair
+ * animates height to --radix-accordion-content-height (unset outside Radix).
+ */
+function animationSampleStyle(ctx: TokenContext, name: string): CSSProperties {
+ if (name === "--animate-rainbow") {
+ return {
+ backgroundImage: `linear-gradient(90deg, ${ctx.color("--chart-1")}, ${ctx.color("--chart-2")}, ${ctx.color("--chart-3")}, ${ctx.color("--chart-1")})`,
+ backgroundSize: "200% 100%",
+ };
+ }
+ if (name.startsWith("--animate-accordion")) {
+ return {
+ "--radix-accordion-content-height": "1rem",
+ overflow: "hidden",
+ } as CSSProperties;
+ }
+ return {};
+}
+
+/** @theme inline animation tokens, collapsed (low traffic). */
+export function AnimationsSection({ ctx, lightCtx, darkCtx }: RowContexts) {
+ return (
+ <CollapsedSection
+ title="Animations"
+ blurb="@theme inline animation tokens: each emits an animate-* utility wired to a keyframe in globals.css."
+ count={animationTokens.length}
+ >
+ {animationTokens.map((token) => (
+ <TokenRow
+ key={token.name}
+ name={token.name}
+ staticDecl={token}
+ ctx={ctx}
+ lightCtx={lightCtx}
+ darkCtx={darkCtx}
+ sample={
+ <div
+ className="rounded-md border px-2.5 py-1.5"
+ style={{ background: ctx.color("--background") }}
+ >
+ <span
+ className="bg-muted inline-block h-4 w-14 rounded-sm"
+ style={{
+ animation: ctx.resolve(token.value),
+ ...animationSampleStyle(ctx, token.name),
+ }}
+ />
+ </div>
+ }
+ />
+ ))}
+ </CollapsedSection>
+ );
+}
+
+/** Breakpoints are deliberately not tokenized; say so instead of inventing. */
+export function BreakpointsNote() {
+ return (
+ <PageSection
+ title="Breakpoints"
+ blurb="No custom breakpoint tokens; Tailwind's default sm / md / lg / xl / 2xl screens."
+ >
+ <></>
+ </PageSection>
+ );
+}
+
+export function Layout() {
+ const { ctx, lightCtx, darkCtx } = useTokenContexts();
+ const rowContexts = { ctx, lightCtx, darkCtx };
+
+ const radiusCount = (radiusEntry ? 1 : 0) + inlineRadii.length;
+ const layoutCount = bannerEntries.length + spacingTokens.length;
+
+ return (
+ <div className="p-6 md:p-10">
+ <div className="mx-auto flex w-full max-w-7xl flex-col gap-10">
+ <PageHeader
+ eyebrow="Design tokens"
+ title="Layout"
+ lede={
+ <>
+ Radii, layout offsets, surface layering, overlay order,
+ animations. Parsed at build time from{" "}
+ <code className="font-mono">src/styles/globals.css</code>; the
+ layer order from{" "}
+ <code className="font-mono">components/ui/layer.tsx</code>.
+ </>
+ }
+ meta={
+ <>
+ {radiusCount} radius tokens · {layoutCount} layout tokens ·{" "}
+ {LAYER_ORDER.length} overlay layers · {animationTokens.length}{" "}
+ animation tokens
+ </>
+ }
+ />
+ <RadiiSection {...rowContexts} />
+ <LayoutOffsetsSection {...rowContexts} />
+ <LayeringSection lightCtx={lightCtx} darkCtx={darkCtx} />
+ <LayerSystemSection ctx={ctx} />
+ <BreakpointsNote />
+ <AnimationsSection {...rowContexts} />
+ <p className="text-muted-foreground text-sm">
+ Component spacing uses Tailwind&apos;s default rem scale (
+ <InlineCode>p-2</InlineCode>, <InlineCode>gap-4</InlineCode>, …).
+ </p>
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/components/design-system/ThemeTokens/Typography.stories.tsx b/web/src/components/design-system/ThemeTokens/Typography.stories.tsx
new file mode 100644
index 0000000000..43a9ed1ae6
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Typography.stories.tsx
@@ -0,0 +1,13 @@
+import preview from "../../../../.storybook/preview";
+import { Typography as TypographyPage } from "./Typography";
+
+const meta = preview.meta({
+ component: TypographyPage,
+ parameters: {
+ layout: "fullscreen",
+ },
+});
+
+// Named after the component so Storybook's single-story hoisting collapses
+// Design / Typography into one sidebar leaf.
+export const Typography = meta.story({});
diff --git a/web/src/components/design-system/ThemeTokens/Typography.tsx b/web/src/components/design-system/ThemeTokens/Typography.tsx
new file mode 100644
index 0000000000..627acb7298
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/Typography.tsx
@@ -0,0 +1,316 @@
+/**
+ * Storybook-only typography reference (Design → Typography),
+ * modeled on Carbon's typography docs: single-sentence typeface specimens
+ * with both weight roles inline, a live type-scale table, and tokenized
+ * usage guidance.
+ *
+ * Every value on this page — font stacks, the two weight roles, the text-*
+ * size tokens and their canonical weights — is parsed at build time from
+ * `src/styles/globals.css` (see parseThemeTokens.ts), so the page cannot
+ * drift from the stylesheet.
+ */
+import {
+ resolveDeclaredValue,
+ type TokenDeclaration,
+} from "./parseThemeTokens";
+import {
+ Eyebrow,
+ InlineCode,
+ PageHeader,
+ PageSection,
+ Panel,
+ parsed,
+} from "./shared";
+
+/** `@theme static` values (font stacks + weight roles) by token name. */
+const staticTokens = new Map(
+ parsed.fontTokens.map((token) => [token.name, token.value]),
+);
+const resolveStatic = (value: string) =>
+ resolveDeclaredValue(value, staticTokens);
+
+const sansToken = parsed.fontTokens.find((t) => t.name === "--font-sans");
+const monoToken = parsed.fontTokens.find((t) => t.name === "--font-mono");
+const weightTokens = parsed.fontTokens.filter((t) =>
+ t.name.startsWith("--font-weight-"),
+);
+const regularWeight = resolveStatic("var(--font-weight-regular)");
+const boldWeight = resolveStatic("var(--font-weight-bold)");
+
+/** `--text-xs`, `--text-sm`, … (their `--font-weight` companions excluded). */
+const sizeTokens = parsed.inlineTokens
+ .filter((t) => /^--text-[a-z0-9]+$/.test(t.name))
+ .sort((a, b) => parseFloat(a.value) - parseFloat(b.value));
+
+const weightTokenFor = (sizeName: string) =>
+ parsed.inlineTokens.find((t) => t.name === `${sizeName}--font-weight`);
+
+/** First family in the (var-resolved) stack, e.g. `Inter` or `ui-monospace`. */
+const familyName = (token: TokenDeclaration) =>
+ resolveStatic(token.value).split(",")[0].trim().replace(/^"|"$/g, "");
+
+const formatPx = (px: number) => `${Number(px.toFixed(2))}px`;
+
+/**
+ * Real usages in `web/src` (grepped, not guessed) — component names cited so
+ * the scale table reads like Carbon's "used for …" guidance but stays honest.
+ */
+const SIZE_USAGE: Record<string, string> = {
+ "--text-xs": "Badge · DataTable cells",
+ "--text-sm": "Button · Input · DropdownMenu",
+ "--text-base": "support-chat intro · eval template detail",
+ "--text-lg": "PageHeader title · OverviewPanel title",
+ "--text-xl": "DialogTitle",
+ "--text-2xl": "CardTitle · splash screen heading",
+ "--text-3xl": "TotalMetric · BigNumber widget",
+};
+
+const SAMPLE_LINE = "Trace every span, score every generation.";
+
+/** One compact scale row: specimen · token · size · usage citation. */
+function TypeScaleRow({ token }: { token: TokenDeclaration }) {
+ const weightToken = weightTokenFor(token.name);
+ const weightValue = weightToken
+ ? resolveStatic(weightToken.value)
+ : undefined;
+ const declaredPx = parseFloat(token.value) * 16;
+ const usage = SIZE_USAGE[token.name];
+
+ return (
+ <div className="grid items-center gap-x-8 gap-y-1 border-t py-3 md:grid-cols-[minmax(0,1fr)_130px_130px_minmax(0,1fr)]">
+ <div className="min-w-0 overflow-hidden">
+ <span
+ title={SAMPLE_LINE}
+ className="text-foreground block truncate"
+ style={{
+ fontSize: token.value,
+ fontWeight: weightValue ? Number(weightValue) : undefined,
+ }}
+ >
+ {SAMPLE_LINE}
+ </span>
+ </div>
+ <div className="flex flex-wrap items-center gap-2">
+ <InlineCode>{token.name.replace(/^--/, "")}</InlineCode>
+ </div>
+ <div className="text-muted-foreground font-mono text-[11px] leading-4">
+ {token.value} / {formatPx(declaredPx)}
+ </div>
+ <div className="min-w-0 font-mono text-[11px] leading-4">
+ {usage ? (
+ <span className="text-foreground">used in · {usage}</span>
+ ) : (
+ <span className="text-muted-foreground">—</span>
+ )}
+ </div>
+ </div>
+ );
+}
+
+/** Typeface specimen: one real sentence with both weight roles inline. */
+function TypefaceSpecimen({
+ token,
+ role,
+}: {
+ token: TokenDeclaration;
+ role: string;
+}) {
+ // Render through the emitted :root var — live truth, same source token.
+ const fontFamily = `var(${token.name})`;
+ const stackCaption = `${token.name}: ${token.value}`;
+ return (
+ <div className="flex min-w-0 flex-col gap-1.5">
+ <Panel>
+ <div className="flex items-start gap-2 border-b px-4 py-3">
+ <Eyebrow>{role}</Eyebrow>
+ </div>
+ <div
+ className="flex grow flex-col gap-3 px-4 py-5"
+ style={{ fontFamily }}
+ >
+ <span className="text-foreground text-3xl font-bold">
+ {familyName(token)}
+ </span>
+ <p
+ className="text-foreground text-lg"
+ style={{ fontWeight: Number(regularWeight) }}
+ >
+ Trace every span at regular {regularWeight},{" "}
+ <span style={{ fontWeight: Number(boldWeight) }}>
+ score every generation at bold {boldWeight}.
+ </span>
+ </p>
+ </div>
+ </Panel>
+ <code
+ className="text-muted-foreground truncate font-mono text-[10px] leading-4"
+ title={stackCaption}
+ >
+ {stackCaption}
+ </code>
+ </div>
+ );
+}
+
+/** Weight-role row: the same sentence at the role's live weight. */
+function WeightRoleRow({ token }: { token: TokenDeclaration }) {
+ const role = token.name.replace("--font-weight-", "");
+ return (
+ <div className="grid items-center gap-x-8 gap-y-1 border-t py-3 md:grid-cols-[minmax(0,1fr)_260px]">
+ <span
+ className="text-foreground block truncate text-xl"
+ title="The quick brown fox jumps over the lazy dog"
+ style={{ fontWeight: Number(token.value) }}
+ >
+ The quick brown fox jumps over the lazy dog
+ </span>
+ <div className="text-muted-foreground flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[11px] leading-4">
+ <span>
+ {token.name}: {token.value}
+ </span>
+ <span>
+ {role === "bold" ? "· the font-bold utility" : "· every text-* size"}
+ </span>
+ </div>
+ </div>
+ );
+}
+
+/** Mono conventions, each rendered with the exact classes the app uses. */
+const MONO_EXAMPLES: Array<{
+ label: string;
+ className: string;
+ sample: string;
+ seenIn: string;
+}> = [
+ {
+ label: "Eyebrow label",
+ className:
+ "font-mono text-[10px] tracking-[0.05em] uppercase text-muted-foreground",
+ sample: "Production · EU region",
+ seenIn: "EnvLabelBadge, section eyebrows on this page",
+ },
+ {
+ label: "Metric",
+ className: "font-mono text-sm tabular-nums text-foreground",
+ sample: "1,284 ms · 8,192 tok · $0.0042",
+ seenIn: "chart tooltips, ExperimentPeekFooter",
+ },
+ {
+ label: "Identifier",
+ className: "font-mono text-[11px] text-muted-foreground",
+ sample: "trace 7f3a9c2e-41d0-4b8a-9a71",
+ seenIn: "ModernSession header, TraceEventsRow",
+ },
+ {
+ label: "Code line",
+ className: "font-mono text-xs text-foreground",
+ sample: '{ "model": "gpt-5", "stream": true }',
+ seenIn: "SessionObservationIO, Codeblock",
+ },
+];
+
+export function Typography() {
+ return (
+ <div className="p-6 md:p-10">
+ <div className="mx-auto flex w-full max-w-5xl flex-col gap-10">
+ <PageHeader
+ eyebrow="Design tokens"
+ title="Typography"
+ lede={
+ <>
+ Two typefaces, two weights, {sizeTokens.length} sizes. Parsed at
+ build time from{" "}
+ <code className="font-mono">src/styles/globals.css</code>.
+ </>
+ }
+ meta={
+ <>
+ {sansToken && `--font-sans "${familyName(sansToken)}"`}
+ {monoToken && ` · --font-mono "${familyName(monoToken)}"`}
+ {` · ${weightTokens.length} weight roles · ${sizeTokens.length} text-* sizes`}
+ </>
+ }
+ />
+
+ <PageSection
+ title="Typefaces"
+ blurb="Sans carries the interface; mono carries everything data-shaped."
+ aside={<InlineCode>@theme static</InlineCode>}
+ >
+ <div className="grid gap-4 lg:grid-cols-2">
+ {sansToken && (
+ <TypefaceSpecimen
+ token={sansToken}
+ role="sans · UI text & body copy"
+ />
+ )}
+ {monoToken && (
+ <TypefaceSpecimen
+ token={monoToken}
+ role="mono · numerals, IDs, code, eyebrows"
+ />
+ )}
+ </div>
+ <p className="text-muted-foreground text-sm">
+ No third face: display text is the sans stack at a larger size.
+ </p>
+ </PageSection>
+
+ <PageSection
+ title="Weight roles"
+ blurb="Two roles: regular and bold. Components never hardcode weight numbers."
+ aside={<InlineCode>{weightTokens.length} roles</InlineCode>}
+ >
+ <div className="flex flex-col">
+ {weightTokens.map((token) => (
+ <WeightRoleRow key={token.name} token={token} />
+ ))}
+ </div>
+ <p className="text-muted-foreground text-sm">
+ <InlineCode>font-medium</InlineCode>,{" "}
+ <InlineCode>font-semibold</InlineCode> and raw numbers are drift.
+ </p>
+ </PageSection>
+
+ <PageSection
+ title="Type scale"
+ blurb="Each size carries its canonical weight. No line-height; opt in with leading-*."
+ aside={<InlineCode>{sizeTokens.length} sizes</InlineCode>}
+ >
+ <div className="flex flex-col">
+ {sizeTokens.map((token) => (
+ <TypeScaleRow key={token.name} token={token} />
+ ))}
+ </div>
+ </PageSection>
+
+ <PageSection
+ title="Mono conventions"
+ blurb="Numerals, IDs, code and eyebrow labels are always mono. Samples use the exact app classes."
+ aside={<InlineCode>--font-mono</InlineCode>}
+ >
+ <div className="flex flex-col">
+ {MONO_EXAMPLES.map((example) => (
+ <div
+ key={example.label}
+ className="grid items-center gap-x-8 gap-y-1 border-t py-3 md:grid-cols-[140px_minmax(0,1fr)_minmax(0,1.2fr)]"
+ >
+ <Eyebrow>{example.label}</Eyebrow>
+ <div className="bg-card min-w-0 rounded-md border px-3 py-2">
+ <span className={`${example.className} block truncate`}>
+ {example.sample}
+ </span>
+ </div>
+ <div className="text-muted-foreground flex min-w-0 flex-col gap-0.5 font-mono text-[10px] leading-4">
+ <span className="break-all">{example.className}</span>
+ <span>as in · {example.seenIn}</span>
+ </div>
+ </div>
+ ))}
+ </div>
+ </PageSection>
+ </div>
+ </div>
+ );
+}
diff --git a/web/src/components/design-system/ThemeTokens/docsChrome.tsx b/web/src/components/design-system/ThemeTokens/docsChrome.tsx
new file mode 100644
index 0000000000..1a632c8bfd
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/docsChrome.tsx
@@ -0,0 +1,125 @@
+/**
+ * Shared presentational chrome for the Design reference pages (Color,
+ * Typography, Layout, Charts).
+ *
+ * The voice borrows from langfuse.com's docs presentation (full-width hairline
+ * dividers, mono uppercase eyebrow labels, restrained monochrome, crop-mark
+ * corner ticks on framed panels) and from Kumo's component docs (muted cell
+ * labels, small mono spec chips, quiet section headers). Everything renders
+ * with the app's own tokens and type classes, so the chrome itself is a
+ * specimen of the design system — in both themes.
+ */
+import { type ReactNode } from "react";
+
+import { cn } from "@/src/utils/tailwind";
+
+/** The app's eyebrow-label convention: tiny, mono, uppercase, tracked. */
+export function Eyebrow({ children }: { children: ReactNode }) {
+ return (
+ <span className="text-muted-foreground font-mono text-[10px] tracking-[0.05em] uppercase">
+ {children}
+ </span>
+ );
+}
+
+/** Small mono chip for utility names, counts and inline values (Kumo-style). */
+export function SpecChip({ children }: { children: ReactNode }) {
+ return (
+ <code className="bg-muted text-foreground rounded-sm border px-1.5 py-0.5 font-mono text-[10px] whitespace-nowrap">
+ {children}
+ </code>
+ );
+}
+
+/** Page header: eyebrow · title · lede · mono meta line (langfuse.com docs). */
+export function DocsPageHeader({
+ eyebrow,
+ title,
+ lede,
+ meta,
+}: {
+ eyebrow: ReactNode;
+ title: ReactNode;
+ lede?: ReactNode;
+ meta?: ReactNode;
+}) {
+ return (
+ <header className="flex flex-col gap-2">
+ <Eyebrow>{eyebrow}</Eyebrow>
+ <h1 className="text-foreground text-3xl font-bold tracking-tight">
+ {title}
+ </h1>
+ {lede !== undefined && (
+ <p className="text-muted-foreground max-w-2xl text-sm">{lede}</p>
+ )}
+ {meta !== undefined && (
+ <p className="text-muted-foreground font-mono text-[11px] leading-4">
+ {meta}
+ </p>
+ )}
+ </header>
+ );
+}
+
+/**
+ * Section with the docs-site rhythm: a full-width hairline, then a quiet
+ * header row (title + blurb left, optional aside right), then content.
+ */
+export function DocsSection({
+ title,
+ blurb,
+ aside,
+ children,
+}: {
+ title: ReactNode;
+ blurb?: ReactNode;
+ aside?: ReactNode;
+ children: ReactNode;
+}) {
+ return (
+ <section className="flex flex-col gap-4 border-t pt-6">
+ <div className="flex items-baseline justify-between gap-4">
+ <div className="flex flex-col gap-1">
+ <h2 className="text-foreground text-lg font-bold">{title}</h2>
+ {blurb !== undefined && (
+ <p className="text-muted-foreground max-w-2xl text-sm">{blurb}</p>
+ )}
+ </div>
+ {aside}
+ </div>
+ {children}
+ </section>
+ );
+}
+
+const TICK_POSITIONS = {
+ tl: "-top-px -left-px border-t border-l",
+ tr: "-top-px -right-px border-t border-r",
+ bl: "-bottom-px -left-px border-b border-l",
+ br: "-bottom-px -right-px border-b border-r",
+} as const;
+
+/**
+ * Hairline panel with crop-mark corner ticks, the framing device langfuse.com
+ * uses for its feature cells. Square corners on purpose — the marks read as
+ * registration ticks on a print sheet.
+ */
+export function CropFrame({ children }: { children: ReactNode }) {
+ return (
+ <div className="bg-card relative flex flex-col border">
+ {(Object.keys(TICK_POSITIONS) as Array<keyof typeof TICK_POSITIONS>).map(
+ (position) => (
+ <span
+ key={position}
+ aria-hidden
+ className={cn(
+ "border-foreground/40 absolute size-2",
+ TICK_POSITIONS[position],
+ )}
+ />
+ ),
+ )}
+ {children}
+ </div>
+ );
+}
diff --git a/web/src/components/design-system/ThemeTokens/parseThemeTokens.ts b/web/src/components/design-system/ThemeTokens/parseThemeTokens.ts
new file mode 100644
index 0000000000..42aac2fec0
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/parseThemeTokens.ts
@@ -0,0 +1,164 @@
+/**
+ * Build-time parser for `src/styles/globals.css`, consumed by the Design
+ * reference pages (Color, Typography, Layout, Charts). The pages import the
+ * stylesheet as raw text (`?raw`) and derive every token from it, so they can
+ * never drift from the file — there is no hand-maintained token list.
+ *
+ * Understands the file's conventions:
+ * - `@theme static` → font stacks + weight roles (emitted as :root vars).
+ * - `@theme inline` → Tailwind mappings, radii, text styles, spacing,
+ * animations (NOT emitted as runtime vars).
+ * - `:root` / `.dark` → the light/dark token values.
+ */
+
+export type TokenDeclaration = {
+ /** Custom property name, e.g. `--background`. */
+ name: string;
+ /** Declared value with whitespace collapsed, e.g. `60 14% 96%`. */
+ value: string;
+};
+
+export type ParsedThemeTokens = {
+ /** `@theme static`: font stacks and weight roles. */
+ fontTokens: TokenDeclaration[];
+ /** `@theme inline`: Tailwind mappings, radii, text styles, spacing, animations. */
+ inlineTokens: TokenDeclaration[];
+ /** `:root`: light theme values. */
+ light: TokenDeclaration[];
+ /** `.dark`: dark theme values. */
+ dark: TokenDeclaration[];
+};
+
+const collapseWhitespace = (text: string) => text.replace(/\s+/g, " ").trim();
+
+/**
+ * Concatenate the balanced-brace bodies of EVERY match of `selector` (must
+ * carry the `g` flag), so a second `:root { … }` (or `.dark`, `@theme …`)
+ * block added later in the file still registers instead of silently dropping
+ * its tokens.
+ */
+function extractBlocks(css: string, selector: RegExp): string {
+ selector.lastIndex = 0;
+ const bodies: string[] = [];
+ let match: RegExpExecArray | null;
+ while ((match = selector.exec(css)) !== null) {
+ const open = css.indexOf("{", match.index);
+ if (open === -1) break;
+ let depth = 0;
+ let closed = false;
+ for (let i = open; i < css.length; i++) {
+ if (css[i] === "{") depth++;
+ else if (css[i] === "}") {
+ depth--;
+ if (depth === 0) {
+ bodies.push(css.slice(open + 1, i));
+ selector.lastIndex = i + 1;
+ closed = true;
+ break;
+ }
+ }
+ }
+ if (!closed) {
+ bodies.push(css.slice(open + 1));
+ break;
+ }
+ }
+ return bodies.join("\n");
+}
+
+/** Remove nested `@keyframes … { … }` blocks (they contain no tokens). */
+function stripKeyframes(content: string): string {
+ let result = "";
+ let i = 0;
+ while (i < content.length) {
+ const at = content.indexOf("@keyframes", i);
+ if (at === -1) {
+ result += content.slice(i);
+ break;
+ }
+ result += content.slice(i, at);
+ let depth = 0;
+ let j = content.indexOf("{", at);
+ if (j === -1) break;
+ for (; j < content.length; j++) {
+ if (content[j] === "{") depth++;
+ else if (content[j] === "}") {
+ depth--;
+ if (depth === 0) {
+ j++;
+ break;
+ }
+ }
+ }
+ i = j;
+ }
+ return result;
+}
+
+/**
+ * Collect every `--token: value;` declaration. Comments are matched (and
+ * skipped) by the same pattern so commented-out declarations never register.
+ */
+function parseDeclarations(content: string): TokenDeclaration[] {
+ const pattern = /\/\*[\s\S]*?\*\/|(--[\w*-]+)\s*:\s*([^;]+);/g;
+ const declarations: TokenDeclaration[] = [];
+ let match: RegExpExecArray | null;
+ while ((match = pattern.exec(content)) !== null) {
+ if (match[1]) {
+ declarations.push({
+ name: match[1],
+ value: collapseWhitespace(match[2]),
+ });
+ }
+ }
+ return declarations;
+}
+
+export function parseThemeTokens(css: string): ParsedThemeTokens {
+ return {
+ fontTokens: parseDeclarations(extractBlocks(css, /@theme\s+static\s*\{/g)),
+ inlineTokens: parseDeclarations(
+ stripKeyframes(extractBlocks(css, /@theme\s+inline\s*\{/g)),
+ ),
+ light: parseDeclarations(extractBlocks(css, /(^|\n)\s*:root\s*\{/g)),
+ dark: parseDeclarations(extractBlocks(css, /(^|\n)\s*\.dark\s*\{/g)),
+ };
+}
+
+const HSL_TRIPLET = /^-?[\d.]+(?:deg)?\s+[\d.]+%\s+[\d.]+%$/;
+
+/**
+ * Substitute `var(--x)` references with their declared values from `map`
+ * (the active theme's tokens), falling back to the var() fallback argument.
+ * The fallback group allows one level of nested parens, so a declaration
+ * like `var(--x, hsl(0 0% 0%))` resolves; deeper nesting passes through raw.
+ */
+export function resolveDeclaredValue(
+ value: string,
+ map: ReadonlyMap<string, string>,
+ depth = 0,
+): string {
+ if (depth > 6) return value;
+ return value.replace(
+ /var\((--[\w-]+)(?:,\s*((?:[^()]|\([^()]*\))*))?\)/g,
+ (whole, name: string, fallback: string | undefined) => {
+ const target = map.get(name);
+ if (target !== undefined) {
+ return resolveDeclaredValue(target, map, depth + 1);
+ }
+ return fallback ?? whole;
+ },
+ );
+}
+
+/**
+ * Turn a (resolved) declared value into a paintable CSS color.
+ * HSL triplets get wrapped (`hsl(60 14% 96%)`); complete color functions
+ * (oklch, …) pass through; non-colors return undefined.
+ */
+export function toCssColor(resolved: string): string | undefined {
+ const value = resolved.trim();
+ if (HSL_TRIPLET.test(value)) return `hsl(${value})`;
+ if (/^(oklch|okhsl|rgba?|hsla?|color)\(/.test(value)) return value;
+ return undefined;
+}
diff --git a/web/src/components/design-system/ThemeTokens/shared.tsx b/web/src/components/design-system/ThemeTokens/shared.tsx
new file mode 100644
index 0000000000..58eeed8757
--- /dev/null
+++ b/web/src/components/design-system/ThemeTokens/shared.tsx
@@ -0,0 +1,384 @@
+/**
+ * Shared machinery for the Design reference pages (Color, Typography,
+ * Layout, Charts). Everything token-shaped is parsed at build time from
+ * `src/styles/globals.css` (see parseThemeTokens.ts), so the pages can never
+ * drift from the stylesheet.
+ *
+ * Two things live here:
+ * - The page chrome, re-exported from docsChrome.tsx (the langfuse.com/Kumo
+ * docs voice) under the neutral names the pages consume.
+ * - The dense token-table machinery: one row per token with light and dark
+ * swatch+value side by side and a compact live usage sample. Samples
+ * repaint under the active Storybook theme (toolbar switcher).
+ */
+import { ChevronRight } from "lucide-react";
+import { type ReactNode, useSyncExternalStore } from "react";
+
+import globalsCss from "../../../styles/globals.css?raw";
+import {
+ CropFrame as Panel,
+ DocsPageHeader as PageHeader,
+ DocsSection as PageSection,
+ Eyebrow,
+ SpecChip as InlineCode,
+} from "./docsChrome";
+import {
+ parseThemeTokens,
+ resolveDeclaredValue,
+ toCssColor,
+ type TokenDeclaration,
+} from "./parseThemeTokens";
+
+export const parsed = parseThemeTokens(globalsCss);
+
+export type TokenEntry = {
+ name: string;
+ light?: TokenDeclaration;
+ dark?: TokenDeclaration;
+};
+
+/** Every `:root`/`.dark` token, joined into light/dark pairs by name. */
+export const rootEntries: TokenEntry[] = (() => {
+ const byName = new Map<string, TokenEntry>();
+ for (const declaration of parsed.light) {
+ byName.set(declaration.name, {
+ name: declaration.name,
+ light: declaration,
+ });
+ }
+ for (const declaration of parsed.dark) {
+ const entry = byName.get(declaration.name);
+ if (entry) entry.dark = declaration;
+ else
+ byName.set(declaration.name, {
+ name: declaration.name,
+ dark: declaration,
+ });
+ }
+ return [...byName.values()];
+})();
+
+export type TokenContext = {
+ dark: boolean;
+ /** Declared value for the context's theme (dark falls back to :root). */
+ decl: (name: string) => string | undefined;
+ /** Fully var()-substituted declared value for the context's theme. */
+ resolve: (value: string) => string;
+ /** Paintable CSS color for a token in the context's theme. */
+ color: (name: string) => string | undefined;
+};
+
+export function buildContext(dark: boolean): TokenContext {
+ const map = new Map<string, string>();
+ for (const declaration of [
+ ...parsed.fontTokens,
+ ...parsed.inlineTokens,
+ ...parsed.light,
+ ]) {
+ map.set(declaration.name, declaration.value);
+ }
+ if (dark) {
+ for (const declaration of parsed.dark)
+ map.set(declaration.name, declaration.value);
+ }
+ const resolve = (value: string) => resolveDeclaredValue(value, map);
+ return {
+ dark,
+ decl: (name) => map.get(name),
+ resolve,
+ color: (name) => toCssColor(resolve(`var(${name})`)),
+ };
+}
+
+const subscribeToThemeClass = (callback: () => void) => {
+ const observer = new MutationObserver(callback);
+ observer.observe(document.documentElement, {
+ attributes: true,
+ attributeFilter: ["class"],
+ });
+ return () => observer.disconnect();
+};
+
+export const useIsDarkTheme = () =>
+ useSyncExternalStore(
+ subscribeToThemeClass,
+ () => document.documentElement.classList.contains("dark"),
+ () => false,
+ );
+
+/** Active-theme context plus fixed light/dark contexts for the value cells. */
+export function useTokenContexts() {
+ const dark = useIsDarkTheme();
+ return {
+ ctx: buildContext(dark),
+ lightCtx: buildContext(false),
+ darkCtx: buildContext(true),
+ };
+}
+
+/* ------------------------------------------------------------------------- *
+ * Token completeness. Every token the parser extracts must appear on exactly
+ * one page; anything unclaimed renders in Color's "Unassigned tokens" group
+ * so nothing can silently vanish. First match wins; each matcher mirrors
+ * what that page's sections actually render.
+ * ------------------------------------------------------------------------- */
+
+export type PageId = "color" | "typography" | "layout" | "charts";
+
+const rootNames = new Set(rootEntries.map((entry) => entry.name));
+
+export const PAGE_TOKEN_MATCHERS: Array<{
+ page: PageId;
+ test: (name: string) => boolean;
+}> = [
+ {
+ page: "charts",
+ test: (n) => /^--(?:chart-\d+|chart-grid|color-\d+)$/.test(n),
+ },
+ { page: "typography", test: (n) => /^--(?:font-|text-)/.test(n) },
+ {
+ page: "layout",
+ test: (n) =>
+ n === "--radius" || /^--(?:radius-|banner-|spacing-|animate-)/.test(n),
+ },
+ // Color is the default home: every remaining runtime (:root/.dark) token
+ // plus the Tailwind color-utility mappings (including disabled built-ins).
+ { page: "color", test: (n) => rootNames.has(n) || n.startsWith("--color-") },
+];
+
+/** Every distinct token name the parser extracted from globals.css. */
+export const allTokenNames: string[] = [
+ ...new Set(
+ [
+ ...parsed.fontTokens,
+ ...parsed.inlineTokens,
+ ...parsed.light,
+ ...parsed.dark,
+ ].map((t) => t.name),
+ ),
+];
+
+export const pageForToken = (name: string): PageId | undefined =>
+ PAGE_TOKEN_MATCHERS.find(({ test }) => test(name))?.page;
+
+/** Tokens no page claims. Rendered on Color; ideally always empty. */
+export const unassignedTokens: string[] = allTokenNames.filter(
+ (name) => pageForToken(name) === undefined,
+);
+
+/** Look a token up across all parser collections, for generic rendering. */
+export function findTokenDeclaration(name: string): {
+ entry?: TokenEntry;
+ staticDecl?: TokenDeclaration;
+} {
+ const entry = rootEntries.find((candidate) => candidate.name === name);
+ if (entry) return { entry };
+ const staticDecl = [...parsed.fontTokens, ...parsed.inlineTokens].find(
+ (candidate) => candidate.name === name,
+ );
+ return staticDecl ? { staticDecl } : {};
+}
+
+/* ------------------------------------------------------------------------- *
+ * Page chrome. The langfuse.com/Kumo docs voice from docsChrome.tsx (mono
+ * uppercase eyebrows, hairline section dividers, quiet headers, spec chips,
+ * crop-mark panels), re-exported under the names the pages consume.
+ * ------------------------------------------------------------------------- */
+
+export { Eyebrow, InlineCode, PageHeader, PageSection, Panel };
+
+/* ------------------------------------------------------------------------- *
+ * Dense token table.
+ * ------------------------------------------------------------------------- */
+
+export function Swatch({ color }: { color: string | undefined }) {
+ if (!color) return null;
+ return (
+ <span
+ aria-hidden
+ className="border-border-contrast inline-block size-3 shrink-0 rounded-sm border align-middle"
+ style={{ background: color }}
+ />
+ );
+}
+
+/**
+ * Table row layout shared by the header row and every token row:
+ * token · light · dark · sample.
+ */
+const ROW_GRID =
+ "grid grid-cols-[minmax(160px,1fr)_minmax(140px,1fr)_minmax(140px,1fr)_minmax(200px,1.1fr)] items-center gap-x-4";
+
+function TableHeader() {
+ return (
+ <div className={`${ROW_GRID} border-b pb-1.5`}>
+ <Eyebrow>Token</Eyebrow>
+ <Eyebrow>Light</Eyebrow>
+ <Eyebrow>Dark</Eyebrow>
+ <Eyebrow>Sample</Eyebrow>
+ </div>
+ );
+}
+
+export function EmptyCell() {
+ return <span className="text-muted-foreground font-mono text-[11px]">—</span>;
+}
+
+/** One canonical (declared) value, with its theme-correct swatch. */
+function ValueCell({
+ decl,
+ paint,
+ emphasized,
+}: {
+ decl: TokenDeclaration | undefined;
+ /** Context of the cell's own theme, so var() refs resolve correctly. */
+ paint: TokenContext;
+ /** The active toolbar theme's cell reads louder. */
+ emphasized: boolean;
+}) {
+ if (!decl) return <EmptyCell />;
+ const swatch = toCssColor(paint.resolve(decl.value));
+ return (
+ <div className="flex min-w-0 items-center gap-1.5">
+ <Swatch color={swatch} />
+ <code
+ className={`${
+ emphasized ? "text-foreground" : "text-muted-foreground"
+ } truncate font-mono text-[11px]`}
+ title={decl.value}
+ >
+ {decl.value}
+ </code>
+ </div>
+ );
+}
+
+export function TokenRow({
+ name,
+ entry,
+ staticDecl,
+ ctx,
+ lightCtx,
+ darkCtx,
+ sample,
+}: {
+ name: string;
+ /** Light/dark pair for :root/.dark tokens. */
+ entry?: TokenEntry;
+ /** Single declaration for @theme (static/inline) tokens. */
+ staticDecl?: TokenDeclaration;
+ ctx: TokenContext;
+ lightCtx: TokenContext;
+ darkCtx: TokenContext;
+ sample: ReactNode;
+}) {
+ return (
+ <div className={`${ROW_GRID} border-b py-1.5`}>
+ <div className="flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5">
+ <code className="text-foreground font-mono text-[11px] break-all">
+ {name}
+ </code>
+ </div>
+ {staticDecl ? (
+ <div className="col-span-2 flex min-w-0 items-center gap-1.5">
+ <Swatch color={toCssColor(ctx.resolve(staticDecl.value))} />
+ <code
+ className="text-foreground truncate font-mono text-[11px]"
+ title={staticDecl.value}
+ >
+ {staticDecl.value}
+ </code>
+ </div>
+ ) : (
+ <>
+ <ValueCell
+ decl={entry?.light}
+ paint={lightCtx}
+ emphasized={!ctx.dark}
+ />
+ <ValueCell decl={entry?.dark} paint={darkCtx} emphasized={ctx.dark} />
+ </>
+ )}
+ <div className="min-w-0 py-0.5">{sample ?? <EmptyCell />}</div>
+ </div>
+ );
+}
+
+/** A titled section holding one dense token table. */
+export function TokenSection({
+ title,
+ blurb,
+ count,
+ sectionSample,
+ children,
+}: {
+ title: string;
+ blurb: string;
+ count?: number;
+ sectionSample?: ReactNode;
+ children: ReactNode;
+}) {
+ return (
+ <PageSection
+ title={title}
+ blurb={blurb}
+ aside={
+ count !== undefined ? (
+ <InlineCode>
+ {count} token{count === 1 ? "" : "s"}
+ </InlineCode>
+ ) : undefined
+ }
+ >
+ {sectionSample && <div className="max-w-sm">{sectionSample}</div>}
+ <div className="flex flex-col">
+ <TableHeader />
+ {children}
+ </div>
+ </PageSection>
+ );
+}
+
+/** Low-traffic group: same table, but behind a native disclosure, collapsed. */
+export function CollapsedSection({
+ title,
+ blurb,
+ count,
+ sectionSample,
+ children,
+}: {
+ title: string;
+ blurb: string;
+ count?: number;
+ sectionSample?: ReactNode;
+ children: ReactNode;
+}) {
+ return (
+ <details className="group border-t pt-6">
+ <summary className="flex cursor-pointer list-none items-start gap-2 [&::-webkit-details-marker]:hidden">
+ <ChevronRight
+ aria-hidden
+ className="text-muted-foreground mt-1.5 size-4 shrink-0 transition-transform group-open:rotate-90"
+ />
+ <div className="flex flex-1 items-baseline justify-between gap-4">
+ <div>
+ <h2 className="text-foreground text-lg font-bold">{title}</h2>
+ <p className="text-muted-foreground max-w-2xl text-sm">{blurb}</p>
+ </div>
+ {count !== undefined && (
+ <InlineCode>
+ {count} token{count === 1 ? "" : "s"}
+ </InlineCode>
+ )}
+ </div>
+ </summary>
+ <div className="flex flex-col gap-3 pt-3 pl-6">
+ {sectionSample && <div className="max-w-sm">{sectionSample}</div>}
+ <div className="flex flex-col">
+ <TableHeader />
+ {children}
+ </div>
+ </div>
+ </details>
+ );
+}
diff --git a/web/storybook/docs/ThemeTokens.mdx b/web/storybook/docs/ThemeTokens.mdx
deleted file mode 100644
index 302d4b86b6..0000000000
--- a/web/storybook/docs/ThemeTokens.mdx
+++ /dev/null
@@ -1,168 +0,0 @@
-import { Meta } from "@storybook/addon-docs/blocks";
-
-<Meta title="Theme Tokens" />
-
-export const Swatch = ({ token, css }) => (
- <div className="flex min-w-0 flex-col gap-1">
- <div
- className="border-border h-12 w-full rounded-md border"
- style={{ backgroundColor: css ?? `hsl(var(--${token}))` }}
- />
- <div
- className="text-muted-foreground font-mono text-xs leading-tight"
- style={{ fontSize: "0.75rem" }}
- >
- --{token}
- </div>
- </div>
-);
-
-export const PairChip = ({ bg, fg, label = "Aa — sample text" }) => (
- <div className="flex min-w-0 flex-col gap-1">
- <div
- className="border-border flex h-12 items-center justify-center rounded-md border px-2 text-xs font-bold"
- style={{
- backgroundColor: `hsl(var(--${bg}))`,
- color: `hsl(var(--${fg}))`,
- }}
- >
- {label}
- </div>
- <div
- className="text-muted-foreground font-mono text-xs leading-tight"
- style={{ fontSize: "0.75rem" }}
- >
- --{bg} / --{fg}
- </div>
- </div>
-);
-
-export const TokenGrid = ({ children }) => (
- <div className="storybook-token-grid">{children}</div>
-);
-
-export const semanticPairs = [
- "primary",
- "secondary",
- "tertiary",
- "accent",
- "destructive",
-];
-
-export const statusPairs = [
- ["light-red", "dark-red"],
- ["light-yellow", "dark-yellow"],
- ["light-green", "dark-green"],
- ["light-blue", "dark-blue"],
- ["accent-light-green", "accent-dark-green"],
- ["accent-light-blue", "accent-dark-blue"],
-];
-
-# Theme Tokens
-
-## Surfaces
-
-<TokenGrid>
- <PairChip bg="background" fg="foreground" />
- <PairChip bg="card" fg="card-foreground" />
- <PairChip bg="popover" fg="popover-foreground" />
- <PairChip bg="header" fg="header-foreground" />
- <PairChip bg="muted" fg="muted-foreground" />
- <PairChip bg="background" fg="foreground-tertiary" label="faint text" />
- <Swatch token="border" />
- <Swatch token="border-contrast" />
- <Swatch token="input" />
- <Swatch token="ring" />
- <Swatch token="surface-code" />
-</TokenGrid>
-
-## Semantic
-
-<TokenGrid>
- {semanticPairs.map((name) => (
- <PairChip key={name} bg={name} fg={`${name}-foreground`} label={name} />
- ))}
-</TokenGrid>
-
-## Langfuse Accents
-
-<TokenGrid>
- {[
- "primary-accent",
- "link",
- "link-hover",
- "control-fill",
- "control-track",
- "muted-blue",
- "muted-green",
- "muted-magenta",
- "muted-gray",
- ].map((token) => (
- <Swatch key={token} token={token} />
- ))}
-</TokenGrid>
-
-## Status and Accent Pairs
-
-<TokenGrid>
- {statusPairs.map(([bg, fg]) => (
- <PairChip key={bg} bg={bg} fg={fg} label={bg.replace("light-", "")} />
- ))}
-</TokenGrid>
-
-## Search Grammar
-
-<TokenGrid>
- {["qlang-field", "qlang-value", "qlang-number", "qlang-keyword"].map(
- (token) => (
- <Swatch key={token} token={token} />
- ),
- )}
-</TokenGrid>
-
-## Sidebar
-
-<TokenGrid>
- <PairChip bg="sidebar-background" fg="sidebar-foreground" />
- <PairChip bg="sidebar-primary" fg="sidebar-primary-foreground" />
- <PairChip bg="sidebar-accent" fg="sidebar-accent-foreground" />
- <Swatch token="sidebar-border" />
- <Swatch token="sidebar-ring" />
-</TokenGrid>
-
-## Find Match
-
-<TokenGrid>
- <PairChip bg="find-match-background" fg="foreground" label="match" />
- <PairChip
- bg="find-match-selected-background"
- fg="find-match-selected-foreground"
- label="selected match"
- />
-</TokenGrid>
-
-## Charts
-
-<TokenGrid>
- {Array.from({ length: 8 }, (_, index) => (
- <Swatch key={index} token={`chart-${index + 1}`} />
- ))}
- <Swatch token="chart-grid" />
-</TokenGrid>
-
-## Heatmap
-
-<TokenGrid>
- {Array.from({ length: 5 }, (_, index) => (
- <Swatch
- key={index}
- token={`color-${index + 1}`}
- css={`var(--color-${index + 1})`}
- />
- ))}
-</TokenGrid>
-
----
-
-Tokens live in `web/src/styles/globals.css`. This page reads them directly, so
-the reference stays aligned with the application theme.
diff --git a/web/types/global.d.ts b/web/types/global.d.ts
index 69778f3df8..0765706c0e 100644
--- a/web/types/global.d.ts
+++ b/web/types/global.d.ts
@@ -22,3 +22,10 @@ declare module "*.md" {
const content: string;
export default content;
}
+
+// Vite raw-text imports (Storybook): used by the Theme Tokens gallery to
+// parse src/styles/globals.css at build time.
+declare module "*.css?raw" {
+ const content: string;
+ export default content;
+}