Repository navigation
Description
Summary
When composing an XDSChatMessage with a bubble plus custom content (e.g. an artifact card, attachment chips, inline citations), the custom content can't be aligned to the same left column as the bubble's text. This makes custom content look out of alignment with the message it belongs to.
Details
Within one assistant message, the left edges differ:
- Bubble text (and the bubble's
name/metadataslots) are inset by the bubble's internal text padding (paddingInline: --spacing-4, ~16px). The docs even notename/metadataare "aligned with bubble text padding." - Custom children of
XDSChatMessage(anything that isn't the bubble) and a standaloneXDSChatMessageMetadatasibling render at the message edge (flush, no inset).
Measured in the ai-chat-artifact template (assistant message, 1280px viewport):
message text (bubble): left = 76px (message edge 60 + bubble paddingInline 16)
standalone timestamp: left = 60px (message edge)
custom artifact card: left = 60–72px (message edge; card border accounts for the rest)
So a custom artifact card placed under the bubble visually steps out of the text column, and a standalone timestamp under it sits at yet another edge.
Why it can't be solved cleanly at the call site
The only workaround is to hardcode marginInlineStart: --spacing-4 on the custom content to mirror the bubble's private padding token. That:
- Duplicates an internal implementation detail of
XDSChatMessageBubble(itspaddingInline), so it silently breaks if that token/padding changes or differs by density (compact/balanced/spacious all currently use spacing-4, but spacious differs for some slots). - Has to be repeated by every consumer that puts a card/attachment/citation in a message.
Proposed solutions (any one)
- An alignment/inset prop on
XDSChatMessage(or a dedicated slot) for custom content, e.g.<XDSChatMessageContent inset>orXDSChatMessageexposing the same text-inset wrapper its bubble/name/metadata use. - Export the bubble's text-inset as a documented spacing token (or a wrapper component like
XDSChatMessageAligned) so custom content can opt into the exact same inset without guessing. - Make
XDSChatMessageMetadata(and custom children) inherit the bubble's text inset by default when composed inside a message that contains a bubble.
Whichever approach, it should be density-aware so the inset always matches the sibling bubble.
Remember the SYNC: blocks in the Chat components (index exports, Storybook stories, Chat block examples).
Context
Surfaced building the ai-chat-artifact page template, which renders a clickable artifact card inside the assistant message. We did NOT ship the marginInlineStart: --spacing-4 workaround (it pins to the bubble's private padding). Related Chat component gaps from the same template: #2572 (top-aligned message list), #2573 (self-scroll phantom scrollbar).
Activity
rubyycheung commentedon Jun 9, 2026
Additional facet of the same gap: custom in-message content also can't stretch to the full width of the message column.
XDSChatMessage's custom-content slot is a flex column withalign-items: flex-start. A custom child (e.g. an artifact card) withwidth: 100%oralignSelf: 'stretch'collapses to ~0 width instead of filling the column — there's no stretchable full-width context, so consumers can only give the child a fixed/maxWidthsize.Repro (measured in the
ai-chat-artifacttemplate): anXDSClickableCardplaced in the assistant message renders at ~1px when givenwidth:100%/alignSelf:stretch; only a definite pixel width renders.So whatever shape the fix for in-message custom content takes (alignment slot / wrapper / prop per the original report), it should ALSO let custom content opt into the full message-column width (stretch), not just align to the text inset.
feat(core): replace ChatMessageContent with a width prop on ChatMessa…
feat(core): add a width prop to ChatMessageBubble so ghost bubbles al…