Skip to content

XDSChatMessage: no way to align custom in-message content (cards, attachments) to the bubble's text column #2574

Closed

Description

@rubyycheung

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 / metadata slots) are inset by the bubble's internal text padding (paddingInline: --spacing-4, ~16px). The docs even note name/metadata are "aligned with bubble text padding."
  • Custom children of XDSChatMessage (anything that isn't the bubble) and a standalone XDSChatMessageMetadata sibling 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 (its paddingInline), 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)

  1. An alignment/inset prop on XDSChatMessage (or a dedicated slot) for custom content, e.g. <XDSChatMessageContent inset> or XDSChatMessage exposing the same text-inset wrapper its bubble/name/metadata use.
  2. 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.
  3. 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

  1. rubyycheung commented on Jun 9, 2026

    @rubyycheung
    ContributorAuthor

    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 with align-items: flex-start. A custom child (e.g. an artifact card) with width: 100% or alignSelf: '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/maxWidth size.

    Repro (measured in the ai-chat-artifact template): an XDSClickableCard placed in the assistant message renders at ~1px when given width: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.

  2. added
    enhancement
    component
    on Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    componentenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions