A list of the person's messages in a long chat. A press on one jumps to that message. Open the outline in the header, then choose an earlier question.
When to use
- Let the person find and jump back to one of their own messages in a long chat.
- Use it with Conversation and Message. Give each
Message.Rootanid, and pass it to the item astarget. - Prefer Popover for a floating panel with other content.
Composition
Polymorphism
ConversationOutline.Item takes asChild. The other parts do not: ConversationOutline.Root renders no element, ConversationOutline.Trigger owns its icon and its label, and ConversationOutline.Content portals into the top layer.
Where to put the trigger
Put the trigger in the chat's header, at every width: a side panel, a full-width page, and a phone. The outline is not a frequent action, so it stays clear of the message box and Conversation.ScrollButton, which own the bottom of the chat. Pass align="end" to ConversationOutline.Content so the outline opens below the trigger and lines up with its end, as the example does.
Render the trigger once the person has sent three messages, as the example above does. With one or two, a scroll is faster, and an outline of one line looks broken. Put it before the header's other actions, so they do not move when it appears.
The outline is at most 22rem wide and 24rem tall, and never taller than the room next to the trigger. On a 320px screen it narrows to fit, and a long message shows as one line that ends in an ellipsis.
How a jump works
A press on an item closes the outline and scrolls its message to the top of the transcript. Set scroll-margin-top on the message, such as scroll-mt-4, for room above it. The scroll is smooth, or instant when the person prefers reduced motion.
A jump up while an answer streams stays at the message: Conversation.Viewport stops following the end. It follows the end again as usual, when the reader scrolls back to the end, presses Conversation.ScrollButton, or sends a message.
Accessibility
ConversationOutline.Content is a dialog named by its trigger, "Conversation outline". Each item is a button named by its message text.
- When the outline opens, focus moves to the item of the current message, which carries
aria-current="location". Tab and Shift+Tab move between the items, and Escape closes the outline and returns focus to the trigger. - After a jump, focus moves to the message, so a screen reader reads on from there and Tab continues from it.
- The item of each message in view shows in the strong color, and the others are muted. The current item says the same thing to a screen reader with
aria-current.
API Reference
ConversationOutline.Root
The root, stateful part that owns the open state. It renders no element.
All props from Popover.Root: open, defaultOpen, and onOpenChange.
ConversationOutline.Trigger
The icon button that opens and closes the outline.
All props from Icon Button except appearance, asChild, icon, intent, label, and type, plus:
ConversationOutline.Content
The panel that lists the messages, one item each. It marks the items of the messages in view and the current one, and keeps the marks up to date while the transcript scrolls.
All props from Popover.Content except preferredWidth.
ConversationOutline.Item
One of the person's messages, as one line of text. A press jumps to the message and moves focus to it.
All props from button except type, plus: