Component API

<chat-message>

Open live example

One conversation entry in a chat-style activity feed. Tool calls and
"thinking" traces are variants of this component rather than separate
ones — they share the same header, collapse behavior, and body card as a
normal message, just dimmed and collapsible with an always-visible summary.

Install

import "@f-ewald/components/chat-message.js";

Usage

<chat-message role="user" author="Freddy" timestamp="2026-07-19T12:00:00Z">
  Write notes.md containing a haiku.
</chat-message>
<chat-message role="agent" variant="tool" collapsible collapsed summary='file_write · {"filename": "notes.md"}'>
  directory: .
  filename: notes.md
</chat-message>

Attributes / properties

PropertyAttributeTypeDefaultDescription
roleroleChatMessageRole"agent"Whose message this is; drives the card background/border.
variantvariantChatMessageVariant"normal"tool/thinking render dimmed and smaller, with tool using monospace for its body.
authorauthorstring""Header label, e.g. "Freddy" or "Architect".
timestamptimestampstring | nullnullISO-8601 timestamp, rendered via relative-time in the header.
summarysummarystring""Always-visible one-liner for tool/thinking variants (e.g. a truncated args preview).
collapsiblecollapsiblebooleanfalseWhether clicking the header/summary toggles the body slot.
collapsedcollapsedbooleanfalseCurrent collapse state (reflected as an attribute).

Events

EventDescription
toggleFired with { collapsed: boolean } when the header/summary is clicked in collapsible mode.

Slots

None.

CSS custom properties

Custom property
--ui-border
--ui-focus-ring
--ui-font
--ui-font-mono
--ui-font-size
--ui-font-size-sm
--ui-font-weight-semibold
--ui-line-height-normal
--ui-primary
--ui-radius
--ui-radius-sm
--ui-surface
--ui-text
--ui-text-muted