Message
kai-message
One element, one object — render a complete message row with markdown, reasoning, tool calls, attachments, and action buttons. The keystone of any custom message list.
- Shadow DOM
- 1 event
- User + assistant roles
- Avatar support
- Custom actions
Preview
Section titled “Preview”Set message in JavaScript (objects can’t be HTML attributes) and listen for kai-message-action:
<kai-message id="msg" style="display:block;"></kai-message>
<script type="module"> import '@kitn.ai/ui/elements'; const msg = document.getElementById('msg');
msg.message = { id: 'm-1', role: 'assistant', content: "Here's the plan:\n\n```js\nconst kit = useChat();\n```", reasoning: { text: 'The user wants X, so I should do Y.' }, tools: [{ type: 'search', state: 'output-available', output: { hits: 3 } }], actions: ['copy', 'like', 'dislike', 'regenerate'], };
msg.addEventListener('kai-message-action', (e) => { console.log(e.detail.action, e.detail.messageId); });</script>messagetakes the whole object. For simple cases, use therole+contentattributes instead.- Markdown is on by default for
role="assistant", off forrole="user". Override with themarkdownboolean. actionsaccepts built-in names ('copy','like','dislike','regenerate','edit') and/or{ id, label, icon?, tooltip? }descriptors. Alternatively, place<kai-action>children in the light DOM.actionsReveal—'always'(default) keeps the action bar visible;'hover'hides it until the row is hovered.
Examples
Section titled “Examples”Rich Assistant Message
Section titled “Rich Assistant Message”A full assistant turn: markdown with a fenced code block, a reasoning block, a tool call, an attachment, and built-in actions.
User Message
Section titled “User Message”A plain user turn with no actions. Markdown is off by default for role="user".
Avatar and Custom Action
Section titled “Avatar and Custom Action”An avatar pulled from message.avatar, plus a custom Share action alongside built-in copy and like.
Actions Reveal on Hover
Section titled “Actions Reveal on Hover”actions-reveal="hover" hides the action bar until the row is hovered — cleaner in dense threads.
| Property | Type | Default | Notes |
|---|---|---|---|
| message | | — | The full message object. Set as a JS property. |
| role | "user" | "assistant" | 'assistant' | Convenience for simple cases when not passing a `message` object. |
| content | string | — | Convenience content (used when `message` is not set). |
| markdown | boolean | — | Force markdown on/off. Defaults to on for assistant, off for user. |
| proseSize | "xs" | "sm" | "base" | "lg" | 'sm' | Text/markdown sizing for the message body. |
| codeTheme | string | 'github-dark-dimmed' | Shiki theme name used for fenced code blocks in the content. |
| codeHighlight | boolean | true | Disable syntax highlighting for code blocks (no Shiki loads). |
| actionsReveal | "always" | "hover" | 'always' | Whether the action bar is always visible (`'always'`, default) or only revealed on hover of the message row (`'hover'`). |
| avatarSrc | string | — | Convenience avatar image URL (used when `message.avatar` is not set). |
| avatarFallback | string | — | Convenience avatar fallback text (used when `message.avatar` is not set). |
Events
Section titled “Events”| Event | Detail | Notes |
|---|---|---|
| kai-message-action | | An action button was clicked. `action` is the built-in name or custom id. |
Composed from
Section titled “Composed from”This element wraps these SolidJS components — reach for them directly when you need finer control than the props expose.