For development, import
UserMessage from @servicetitan/anvil2-ai-kit. For design, find it in the AI Kit Web Component Library file.Options
UserMessage supports arbitrary content and an optional error line with a retry action.Message Content
The bubble caps at 640px and wraps long content; short messages stay compact.content accepts any ReactNode — a plain string, inline composition (Carto Link, strong, etc.), or a rendered Markdown tree.
Error
error renders a message below the bubble. Pair it with onRetry to add a retry action to the toolbar — the button appears only when both are set.
Behavior
The toolbar’s actions and visibility both respond to the message’s content and its position in the conversation.Content Length
The bubble never truncates or clips its content — it only wraps. There’s no maximum height or line count; a long message simply grows taller.Toolbar Actions
The toolbar always shows the timestamp, plus a copy action whenever there’s text to copy; retry joins them only whenerror is also set. Copy is text-only — pass copyText for rich content (Markdown, fragments, images) to keep the message copyable; a message with no text shows no copy button.
Reveal Toolbar on Hover
SetrevealToolbarOnHover on every message except the most recent of its type, so only the latest keeps its toolbar always visible — earlier messages reveal theirs on hover or keyboard focus. This distinction doesn’t apply on touch (coarse-pointer) devices, which always show the toolbar regardless of revealToolbarOnHover.
Usage Guidelines
When to Use
Use the User Message when:- User-sent content – A conversation shows a message the user sent, in a right-aligned bubble.
- Rich user content – The message includes inline links, formatting, or a rendered Markdown tree. Pass copy text so the copy action stays available.
- Failed sends – A message did not deliver and the user needs an error line with a retry action.
When not to use
Avoid using the User Message for:- Agent responses – The agent authored the message. Use the Agent Message instead.
- Media attachments – The user sent a file, image, video, or audio attachment that needs a preview or playback. Use the User Media Message instead.
Keyboard Interaction
Users can navigate and activate toolbar actions using standard keyboard controls; focus also reveals a hidden toolbar.Code
- Implementation
- UserMessage Props
Common Examples
To use theUserMessage, 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
Passerror 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. SetrevealToolbarOnHover 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.copyai-kit.messageToolbar.copiedai-kit.messageToolbar.retryai-kit.messageToolbar.userActions
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.