Skip to main content

Common Examples

To use the UserMessage, pass content and a required timestamp. The bubble right-aligns with a 24px left gutter. The kit forbids children.
content accepts a string, inline markup, or a Markdown tree. Copy is text-only: pass copyText when content is rich so the copy action stays available. When neither yields text, the copy button is omitted.

Content length

Long messages wrap inside the bubble.

Error and retry

Pass error to render a line below the bubble. onRetry shows a refresh action only when error is also set.

Toolbar

The toolbar always includes copy (when copyable) and the formatted timestamp. Set revealToolbarOnHover so a chat list can hide the toolbar until hover or focus, typically on every message except the latest. Coarse pointers always show the toolbar. Keyboard focus reveals it.

Internationalization

The action toolbar owns these localized strings:
  • ai-kit.messageToolbar.copy
  • ai-kit.messageToolbar.copied
  • ai-kit.messageToolbar.retry
  • ai-kit.messageToolbar.userActions
Localize content and error before passing them. Mount AiKitIntlProvider inside CartoTheme to switch the toolbar strings.

React Accessibility

  • The toolbar groups user message actions under a localized name.
  • Timestamp is always present in the toolbar.
  • Hover-hidden toolbars remain reachable from the keyboard.
Last modified on August 28, 2026