AI · Component Template
AI Chat Interface
Every state of an AI chat, made to feel alive: the composer glides down as one object, a beam circles it while it thinks, and the answer writes itself word by word.
Live demo
Pick a suggestion to watch the answer stream in, or press Stop halfway through.
The Prompt
Build a complete AI chat screen for Fieldnote, an assistant that answers from a team's recorded research interviews, and make every state of it feel alive. The page opens on a centered greeting with the composer and three suggestion cards. Ask something, and the composer glides to the bottom of the screen as one object (a view transition), the room's ambient light swells, a beam starts circling the composer's border, the thinking steps tick past and fold into a disclosure, and the answer writes itself word by word with formatting, citations and a code block. Match my project's existing stack, conventions, and design tokens. If there are none, output a single HTML file with inline CSS and JavaScript and zero dependencies. Replies are scripted in the file; no network requests.
LOOK
- Page #07050C, text #F2F2F5, secondary at 64%, hairlines at 12%. Accents: lilac #C9B8FF and rose #FF6FA0, used for light, never for body text.
- Two huge blurred discs of violet (#7B5CFF, top) and rose (#FF5C93, lower right) drift slowly behind everything. Their opacity is multiplied by 0.55 + 0.75 x busy, where busy is a registered custom property that transitions between 0 and 1 over 900ms and is switched with :root:has(.app.busy). Film grain at 9%.
- Glass for the composer and suggestion cards: tint #2A2338 at 48%, backdrop blur 22px, hairline edge. Cards light under the pointer.
- ui-sans-serif, system-ui. Greeting clamp(34px, 4.6vw, 64px), weight 640, letter-spacing -0.05em. Answers 17px / 1.6.
LAYOUT
- Two columns: a 264px sidebar and the main area. Under 820px the sidebar is hidden.
- Sidebar: a gradient mark and "Fieldnote"; an outlined button "New question"; two groups of past conversations as quiet buttons.
- Main, fresh state: a three-row grid (1fr, auto, 1fr) holding the greeting ("What do you want to know?" and "Fieldnote answers from 214 interviews your team has recorded, and shows which ones."), then the composer, then the suggestion cards.
- Main, conversation state: the log scrolls above, the composer is pinned below, and a small line reads "Scripted demo. Nothing you type leaves this page."
- Messages sit in a 760px column. The user's is a right-aligned bubble with one squared corner; the assistant's is plain text on the page, no bubble.
COMPOSER
- A glass pill, radius 28px: an auto-growing textarea (to 160px) and a 46px round button.
- The button's arrow is one clip-path polygon that morphs into a square "stop" while an answer is being written, and the button turns rose. Its label switches between Send and Stop. It is disabled when there is nothing to send.
- Border beam: a ::before with a conic gradient whose start angle is a registered @property animated through 360 degrees every 2.2s, masked to a 1.5px ring, with opacity bound to the busy property.
- Enter sends, Shift+Enter makes a new line; ignore Enter during IME composition. Focus shows as a brighter inner ring on the pill, not an outline on the textarea.
THE FIRST QUESTION
- Give the composer view-transition-name: composer. On the first send, do the layout change (drop the "fresh" class, append the user's message) inside document.startViewTransition, with the group's timing set to a spring easing over 560ms, and start the reply only after updateCallbackDone resolves so the messages are in order. "New question" plays it in reverse.
ANSWERING
- Thinking: a pulsing dot and a shimmering line of text (a moving gradient clipped to the text) that steps through two or three phrases about a second apart ("Searching 214 interviews for onboarding", "Found 38 that mention the first week").
- Then replace it with a details element, "Thought for 3 s", containing those steps as a list, followed by the answer.
- Rendering: a small formatter for paragraphs, bulleted and numbered lists, bold, inline code, fenced code with a little SQL highlighting, and citation markers like [1] that become small round chips. A row of source chips ends the answer.
- Streaming without layout tricks: render the whole answer at once with every word in its own span, hidden with display: none. Switch the words on in order, 16 to 46ms apart (70ms per line inside code), each fading up from a 5px blur. Hide any block that has no visible word yet with :not(:has(.on)), so the answer grows naturally.
- Keep the log pinned to the end while writing, unless the reader has scrolled more than 140px away.
- Stop: cancels at once, removes the unwritten words and adds "Stopped."
- When finished, fade in "Copy" and "Try again". Code blocks have their own Copy button.
SCRIPT
- Three questions with full answers: "What did people say about onboarding?" (three themes with counts, one quote, two sources), "Draft five interview questions about pricing" (a numbered list and a closing note), "Write a query for accounts that churned after a price change" (a SQL block and a result).
- Anything else gets an honest reply saying the demo only knows those three and that a real build would stream the model's reply the same way.
MOTION
- Load: greeting words rise from clipping boxes; the paragraph, composer and cards sharpen from a blur and settle on a CSS spring (a damped spring sampled into linear()). New messages land with a small rise and scale on the same spring.
ACCESSIBILITY
- The log has role="log". Each answer is aria-busy while it is being written and is announced once when it finishes, not word by word.
- The textarea has a visually hidden label. All actions are real buttons.
- prefers-reduced-motion: answers appear whole, no thinking delay, no beam, shimmer or view transition.
NEVER
- No fake network calls, spinners or random delays dressed up as latency.
- No typing indicator of three bouncing dots.
- No avatar circles on every message.
- No layout jump when an answer starts: reserve nothing, and let it grow.
- No send on a bare Enter while an answer is still being written.
- CopyThe full prompt, one click.
- PasteInto Cursor, Claude Code, or any agent.
- CompareAgainst the live demo above.