Chat card
ProA card in the agent's answer for something outside the chat: the browser tab it works in, a file it made, a page or a pull request it changed. Its picture sits beside its name and opens whole; while the agent works the picture holds the light and the change lands in it.
npx shadcn@latest add @pixilui-pro/chat-cardPreview
import { useRef, useState } from "react";
import { Button } from "../../../registry/ui/button/button";
import { ChatCard, type ChatCardHandle } from "@/components/pixilui/chat-card";
import { ChatCardPicturesStyle, chatCardMarks, examplePictures } from "@/components/pixilui/chat-card.examples";
// The first option of each knob is the demo's default; the docs preview starts there.
export const knobs = {
kind: ["pull request", "file", "Notion page", "sheet", "browser tab", "plain"],
ending: ["done", "stopped", "failed", "gone"],
} as const;
const KIND = { "pull request": "pr", file: "file", "Notion page": "notion", sheet: "sheet", "browser tab": "browser", plain: "plain" } as const;
const ANSWER = { fontSize: "var(--pixilui-text-answer)", lineHeight: "var(--pixilui-text-answer-leading)", letterSpacing: "var(--pixilui-text-answer-tracking)" };
/** A card in the agent's answer: the thing's picture builds under the held light as the work lands, then it rings out, or ends stopped, failed or gone. */
export default function ChatCardDemo({ kind = "pull request", ending = "done" }: KnobValues<typeof knobs>) {
const ref = useRef<ChatCardHandle>(null);
const [run, setRun] = useState(0);
const k = KIND[kind];
const play = async () => {
const c = ref.current?.card;
if (!c || !c.work) return;
void c.light(true);
const halt = ending === "stopped" ? setTimeout(() => c.halt?.(), 900) : undefined;
const r = await c.work({ fail: ending === "failed" });
clearTimeout(halt);
if (r === "failed") {
void c.light(false);
void c.ring({ fam: "fail" });
c.end("failed", c.failWord ?? "failed");
} else if (r === "stopped") c.end("stopped", "stopped");
else {
void c.light(false);
void c.ring();
if (ending === "gone") c.end("gone", "deleted");
}
};
return (
<div className="grid w-full max-w-xl gap-3 rounded-panel bg-surface p-5 elevation-raised">
<ChatCardPicturesStyle />
<p className="m-0 text-foreground" style={ANSWER}>
{k === "browser" ? "Refunding the second charge in your Stripe, in the tab beside this chat." : k === "plain" ? "The refund policy is in your docs." : "Raised the refund limit to $500 where the team will see it."}
</p>
<ChatCard
key={`${kind}${ending}${run}`}
ref={ref}
kind={k}
blank={k !== "browser" && k !== "plain"}
title={k === "plain" ? "refund-policy.md" : k === "browser" ? "Payments – Northbeam" : undefined}
meta={k === "plain" ? "Markdown · 4 KB" : k === "browser" ? "dashboard.stripe.com" : undefined}
tile={k === "plain" ? "file" : undefined}
mark={k === "browser" ? "stripe" : undefined}
badge={k === "browser" ? "chrome" : undefined}
page={k === "browser" ? examplePictures().tab!.page() : undefined}
paint={k === "browser" ? examplePictures().tab!.paint : undefined}
pictures={examplePictures()}
marks={chatCardMarks}
onReady={(c) => {
if (k === "browser") c.freeze({ scene: "list", filtered: true, query: "Lena Ortiz", at: "row-b", light: true, meta: "dashboard.stripe.com" });
else if (k !== "plain") setTimeout(() => void play(), 400);
}}
/>
{k !== "browser" && k !== "plain" ? (
<div>
<Button variant="secondary-2" size="sm" onClick={() => setRun((r) => r + 1)}>
Replay
</Button>
</div>
) : null}
</div>
);
}When to use
Use it when
- Something the agent made or changed in another app: a file, a Notion page, a pull request, a sheet, with its picture.
- The browser tab the agent works in, with its cursor, and a hand-off when the site needs the person (Take over, Hand back).
- A thing that didn't end done: stopped, failed or gone, said in its meta.
Use something else when
- A link inside running text: keep it a link.
- A source behind a claim: use the reasoning trail's citation chip.
- A generic link preview with no picture of the thing.
Installation
Join the waitlist and we'll email you when PixilUI launches. The preview, props and docs stay open until then.
Pro installs with the same CLI as the free items. One command adds chat-card.tsx and the free aurora-light.tsx, the free avatar.tsx, the free button.tsx, the free kbd.tsx and the free tooltip.tsx it uses; your license key goes in once, as in Installation.
{
"registries": {
"@pixilui-pro": {
"url": "https://pixilui.com/r/pro/{name}.json",
"headers": { "Authorization": "Bearer ${PIXILUI_TOKEN}" }
}
}
}npx shadcn@latest add @pixilui-pro/chat-cardAdds chat-card.tsx with aurora-light.tsx, avatar.tsx, button.tsx, kbd.tsx and tooltip.tsx, and installs clsx and tailwind-merge. The CLI reads PIXILUI_TOKEN from .env.local; if this computer has not logged in yet, run npx pixilui@latest login once.
components/pixilui/chat-card.tsxthe item, 1074 linescomponents/pixilui/aurora-light.tsxused inside, freecomponents/pixilui/avatar.tsxused inside, freecomponents/pixilui/button.tsxused inside, freecomponents/pixilui/kbd.tsxused inside, freecomponents/pixilui/tooltip.tsxused inside, freeIt uses Aurora light, Avatar, Button, Kbd and Tooltip: add them the same way. Then npm i clsx tailwind-merge, and add the foundation once per app, as in Installation.
Usage
import { ChatCard } from "@/components/pixilui/chat-card";
<ChatCard onReady={onReady} />A lone card is 360 wide at most, a live card 480; under 420 a small card is its row alone, and at 360 long names truncate before the state words.
API reference
kindstring"plain"plain (a link), browser (the tab the agent works in), or a thing in pictures.kinds (file, notion, pr, sheet in the examples).titlestring–Its name.metastring–Where it lives.hrefstring–Where it opens.tilestring–A plain card's tile: an icon id (file, browse).markstring–A product's favicon in the tile, by its mark id (stripe), in place of an icon.badgestring–The app it is open in, on the tile (a mark id: chrome).actionChatCardAction–A plain card's button in place of the arrow.size"small" | "big"–A live card's size.blankboolean–A thing card starts unmade (the work lands in it).pagestring–A browser card's picture: its markup (the Stripe tab in the examples).paintChatCardLiveOptions["paint"]–Sets a frozen browser picture's own state (the examples' tab.paint).youstring–Your name, for your coin by your cursor.openChatCardLiveOptions["open"]–The Open (or Download) button.picturesChatCardPictures–The pictures (the examples' chatCardPictures).marksRecord<string, () => string>–Product marks by id (Chrome, Stripe, Notion, GitHub, Google Drive), as markup; each call is a fresh copy.onReady(card: ChatCardLiveCard & Partial<ChatCardThingCard>) => void–Builds the card's first moment (a frozen state: card.freeze, card.end).Also takes every native <div> attribute except title, and a ref.
Keyboard
Accessibility
- A plain card's row is a link; a live card's is a button with aria-expanded, labelled by its name and where it lives.
- The picture is role img with a label; the picture, the light and the cursors are aria-hidden.
- Open and Download are named links with the locked tooltip; on touch every button reaches 44.
- Reduced motion: the glide, the typing, the cursors and the swaps happen at once; a run settles to the same end.
Motion
- Small to big and back: the view grows out of the picture (FLIP, 280ms on the out curve) and the card's height follows.
- The agent's hands on the tab: the Aurora light blooms from the picture and holds; done rings it out (the browser tab adds the pop).
- Cursors glide, shorter trips quicker (520ms at most); a click dips the arrow and opens a ring; you type slower and unevenly than the agent.
- Gone: the picture drains to grey at half strength and Open fades out. The name and meta change with the quiet swap.