Conversation
NewScrolling chat area that sticks to the bottom while answers stream, pauses when you scroll up, and jumps back down.
Assistant
useMemo caches a value; useCallback caches a function. useCallback(fn, deps) is the same as useMemo(() => fn, deps).
Installation
$ pnpm dlx shadcn@latest add @synccn/conversationFirst time in this project? Connect synccn with one command.
Usage
import { Conversation } from "@/components/ui/conversation";<Conversation className="flex-1" empty={<PromptSuggestions … />}>{messages}</Conversation>API reference
Generated from the component's TypeScript types, so it always matches the code.
Conversation
Scrolling message list for chat: sticks to the bottom as answers stream in, stops when the person scrolls up to read, and shows a button to jump back down.
- children
React.ReactNodeMessages.
- follow
booleanDefault
trueKeeps the newest message in view while the person is at the bottom, including while it streams.
- empty
React.ReactNodeShown when there are no children, such as suggestions.
- aria-label
stringAccessible name.
- className
stringExtra classes for the root element. Give it a height (h-96, flex-1…); the messages scroll inside it.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ArrowDown
Used by
Accessibility
- The message list is a log region, so new messages are announced. A button to jump to the latest message appears when you scroll up.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: log
- ARIA attributes: aria-label, aria-relevant