A support ticket triaged by an AI. Under the glass every chip and button turns into the field or tool call behind it, and both messages turn into their tokens in place with `XrayLensText`: the reply tinted by confidence, the customer's message with the extracted entities outlined. The lens is `size="36%"`, the switch sits under the card and flips the whole ticket, and on a phone the lens tours the spots by itself.
@keyframeui
registry/demos/xray-lens-demo.tsx
import type { ReactNode } from "react";
import { XrayLens, XrayLensSpot, XrayLensText } from "@/components/ui/xray-lens";
// A spot's box in the xray: a dashed outline exactly where the UI element sits.
const box = "outline-1 -outline-offset-1 outline-dashed outline-sky-400/50 bg-sky-400/[0.07]";
function Value({ children, className }: { children: ReactNode; className?: string }) {
return (
<span
className={`grid size-full place-items-center font-mono text-[11px] leading-none whitespace-nowrap ${className ?? "text-amber-300"}`}
>
{children}
</span>
);
}
function Chip({ dot, children }: { dot: string; children: ReactNode }) {
return (
<span className="inline-flex h-6 items-center gap-1.5 rounded-full bg-zinc-100 px-2.5 text-xs font-medium text-zinc-700 dark:bg-zinc-800 dark:text-zinc-300">
<span className={`size-1.5 rounded-full ${dot}`} />
{children}
</span>
);
}
const MESSAGE =
"I was charged twice for Pro this month, once on Oct 2 and again on Oct 3. Could you refund the extra $49.00?";
// The reply as the model streamed it: each token with its probability. The dates and the
// amount are where it was least sure.
const REPLY: [string, number][] = [
["Hi", 0.99], [" Maya", 0.98], [",", 0.99], [" sorry", 0.93], [" about", 0.97], [" that", 0.98],
[".", 0.99], [" I", 0.95], ["'ve", 0.97], [" refunded", 0.9], [" the", 0.99], [" duplicate", 0.88],
[" $", 0.7], ["49", 0.62], [".", 0.9], ["00", 0.95], [" charge", 0.97], [",", 0.96], [" so", 0.9],
[" it", 0.97], [" should", 0.82], [" be", 0.99], [" back", 0.96], [" on", 0.95], [" your", 0.98],
[" card", 0.97], [" in", 0.94], [" 5", 0.41], [" to", 0.7], [" 7", 0.38], [" days", 0.93], [".", 0.99],
];
function Ticket() {
return (
<div className="flex flex-col gap-5 p-5 sm:p-6">
<div className="flex items-start justify-between gap-4">
<XrayLensSpot
label="customer = cus_8Hq2nL"
xrayClassName={box}
xray={
<span className="flex h-full flex-col justify-center gap-1.5 pl-2 font-mono text-[11px] leading-none">
<span className="text-emerald-300">"cus_8Hq2nL"</span>
<span className="text-zinc-400">
plan <span className="text-emerald-300">pro</span> · ltv{" "}
<span className="text-amber-300">1188</span>
</span>
</span>
}
className="flex items-center gap-3"
>
<span className="grid size-10 place-items-center rounded-full bg-gradient-to-br from-amber-200 to-rose-300 text-sm font-semibold text-rose-950">
MC
</span>
<span className="flex flex-col">
<span className="text-sm font-medium text-zinc-900 dark:text-zinc-50">Maya Chen</span>
<span className="text-xs text-zinc-500">maya@northwind.io</span>
</span>
</XrayLensSpot>
<XrayLensSpot
label="received_at"
xrayClassName={box}
xray={<Value>1760531412</Value>}
className="pt-1 text-xs text-zinc-500 tabular-nums"
>
2 min ago
</XrayLensSpot>
</div>
<div className="flex flex-wrap gap-2">
<XrayLensSpot
label="classify.intent"
xrayClassName={box}
xray={<Value className="text-emerald-300">"refund"</Value>}
>
<Chip dot="bg-sky-500">Billing</Chip>
</XrayLensSpot>
<XrayLensSpot label="classify.sentiment" xrayClassName={box} xray={<Value>-0.72</Value>}>
<Chip dot="bg-rose-500">Frustrated</Chip>
</XrayLensSpot>
<XrayLensSpot label="route.priority = p1" xrayClassName={box} xray={<Value>sla 2h</Value>}>
<Chip dot="bg-amber-500">Urgent</Chip>
</XrayLensSpot>
</div>
<XrayLensText
text={MESSAGE}
entities={[
{ text: "charged twice", label: "extract.issue = duplicate_charge" },
{ text: "$49.00", label: "extract.amount = 4900" },
]}
label="input · 31 tokens"
className="text-[15px] leading-relaxed text-pretty text-zinc-700 dark:text-zinc-300"
/>
<XrayLensSpot
label="generate.reply"
xrayClassName={box}
xray={
<span className="absolute top-4 left-4 font-mono text-[11px] leading-4">
<span className="text-violet-300">generate</span>
<span className="text-zinc-400">
() · <span className="text-amber-300">61</span> tok · <span className="text-amber-300">412</span>ms
</span>
</span>
}
className="rounded-xl bg-zinc-50 p-4 ring-1 ring-zinc-950/5 dark:bg-zinc-900 dark:ring-white/10"
>
<div className="flex items-center justify-between text-xs leading-4">
<span className="font-medium text-zinc-900 dark:text-zinc-100">Suggested reply</span>
<XrayLensSpot
as="span"
label="eval.confidence"
xrayClassName={box}
xray={<Value>p 0.94</Value>}
className="inline-block text-zinc-500 tabular-nums"
>
94% confident
</XrayLensSpot>
</div>
<XrayLensText
tokens={REPLY.map(([text, p]) => ({ text, p }))}
label="output · logprobs"
className="mt-2 text-sm leading-relaxed text-pretty text-zinc-600 dark:text-zinc-400"
/>
</XrayLensSpot>
<div className="flex items-center gap-2">
<XrayLensSpot
label="tool_call · stripe"
xrayClassName={box}
xray={<Value className="text-violet-300">refunds.create()</Value>}
>
<button
type="button"
className="h-9 rounded-lg bg-zinc-900 px-3.5 text-sm font-medium text-white transition-colors hover:bg-zinc-800 dark:bg-white dark:text-zinc-900 dark:hover:bg-zinc-200"
>
Refund $49.00
</button>
</XrayLensSpot>
<XrayLensSpot
label="tool_call · helpdesk"
xrayClassName={box}
xray={<Value className="text-violet-300">reply.send()</Value>}
>
<button
type="button"
className="h-9 rounded-lg px-3.5 text-sm font-medium text-zinc-700 ring-1 ring-zinc-950/10 transition-colors hover:bg-zinc-50 dark:text-zinc-300 dark:ring-white/15 dark:hover:bg-zinc-900"
>
Send reply
</button>
</XrayLensSpot>
</div>
</div>
);
}
export function XrayLensDemo() {
return (
<section className="w-full max-w-xl">
<XrayLens
size="36%"
rest={{ x: 0.26, y: 0.26 }}
labels={["Ticket", "Model"]}
toggleClassName="top-full right-auto bottom-auto left-1/2 mt-4 -translate-x-1/2"
surface={<Ticket />}
xray={
<div className="absolute inset-0 bg-[linear-gradient(rgb(56_189_248/0.07)_1px,transparent_1px),linear-gradient(90deg,rgb(56_189_248/0.07)_1px,transparent_1px)] bg-size-[16px_16px]" />
}
xrayClassName="bg-[#060a12] text-sky-100"
className="rounded-2xl bg-white shadow-[0_1px_2px_rgb(0_0_0/0.05),0_16px_40px_-20px_rgb(0_0_0/0.3)] ring-1 ring-zinc-950/5 dark:bg-zinc-950 dark:ring-white/10"
/>
<p className="mt-20 text-center text-sm text-zinc-500">
Point at the ticket to see what the model read and returned, or flip the whole card.
</p>
</section>
);
}
Live preview, examples and props: https://keyframeui.com/components/xray-lens#xray-lens-demo




















