Conversation
A chat's thread: a new reply starts in view, then it follows, and a reply is announced once.
When to use it: For a chat with an AI agent, in an app, a side panel or a help sheet. Starter prompts until it starts.
Example
Guidelines
- Preserve access around motion: respect reduced-motion preferences, provide pause or stop controls where required, avoid harmful flashing and keep content and controls usable.
motion.purpose - Design loading, empty, error and success states for every view, each saying what happened and what to do next. An error says what is wrong and what to do ("Enter a date after today"), never "Invalid" or "Error" alone.
composition.states - Keep focus visible: the kit's ring, or a replacement at least as visible. Draw focus styles on :focus-visible, so a mouse click leaves no ring. A control that takes focus stops clear of every sticky bar, top and bottom, with its ring in view: give the controls a scroll margin of the bar's height plus room.
a11y.focus-visible
Add it to your project
It’s included in turtlekit.css and the turtlekit package: install it.
Your AI will also copy only this component, and what it needs, into your project. That comes with Turtlekit Pro, opening soon. Hear when it opens.
In detail
The thread of a chat with an AI agent: its Messages, oldest first, in a named region that scrolls (it fills its parent's height, or height). On first paint it shows the latest turn. A new turn's start lands near the top of the view with a peek of the turn before, and a reply grows into the view without moving it; once the reply fills the view the thread follows its newest line. Any scroll of the reader's stops following at once, and "Jump to latest" takes them back (smooth, instant under reduced motion). Older turns added above keep the reader's place, and turns scrolled out of view above fade at the region's top edge. One status region says when a reply starts and, once, when it ends (its text, or the Message's announcement); never word by word, and never for turns loaded with the page. With no turns, the region opens at its top with a welcome: title, description and up to four starters (onStarter), gone once the first turn is there and back when the turns are cleared. headingLevel (default 2) sets the welcome's and each turn's heading level.
Styles: css/conversation.css.
How it’s built
The engineering patterns inside Conversation, each explained in Turtlekit Editorial.
Headless components and providers
Messages inside read the thread's context to report a new turn and its start and end, and take its heading level.
Deriving state
The welcome shows exactly while there are no children turns; nothing is stored, so clearing the turns brings it back.
Empty state
The empty thread is a designed welcome: what it can do in one line and the starter prompts as buttons.
Effect separation
Following lives in a plain DOM engine bound once in a layout effect (scroll, wheel, touch, keys and a resize observer), apart from rendering.
Latest ref
The announcement words sit in a ref, so the stable context callbacks read the current labels.