Skip to main content

Common Examples

To use the ChatHistory, pass configured conversations through items, handle selection through React Aria’s selection APIs, and use onNewChat to start a conversation.
Selection is fixed to single. Omit items or pass an empty array to render only the New Chat button.

Selected and unread

selectedKeys controls the active conversation. Set unread on an item to add a status dot and localized screen-reader text.

Subtitle

Every item requires a subtitle, typically a relative timestamp or last-message stamp. The component renders it verbatim; your application owns formatting and relative-time policy.

Overflow

Labels and subtitles truncate to one line. Place ChatHistory in a height-constrained container so long lists scroll instead of growing the rail.

Internationalization

ChatHistory owns these localized strings:
  • ai-kit.chatHistory.newChat
  • ai-kit.chatHistory.list
  • ai-kit.chatHistory.unread
  • ai-kit.chatHistory.recents
Localize each item’s label and subtitle before passing it. Mount AiKitIntlProvider inside CartoTheme to switch the built-in strings.

React Accessibility

  • React Aria supplies single-selection listbox semantics, arrow-key navigation, and typeahead.
  • Each item label is its accessible name; subtitle is its accessible description.
  • Unread items include localized hidden text. The visual status dot is decorative.
  • Pass aria-label or aria-labelledby to override the localized list name.
Last modified on August 28, 2026