XDSChatTokenizedText@xds/core · Chat
Usage
XDSChatMessageList is the scrollable container for chat messages. It renders children in a flex column with role="log" for accessibility, provides density context to child messages, and supports infinite scroll for loading older messages. Use it inside XDSChatLayout for full-page chat with auto-scroll and composer docking, or standalone for embedded message panels.Best practices
| Guidance | Practices |
|---|---|
| Do | Compose messages using MessageList > Message > Bubble for consistent sender-aware styling and density. |
| Do | Set the density prop to control spacing globally — compact for sidebars, balanced for most views, spacious for long-form reading. Individual messages can override. |
| Do | Use the group prop on bubbles (first, middle, last) when a single sender sends multiple consecutive messages — it tightens corner radius to visually connect them. |
| Do | Use XDSChatSystemMessage with variant="divider" for date separators and default for inline status notices like joins, leaves, or topic changes. |
| Do | Put name on the first bubble and metadata on the last bubble in a message so they align with the bubble's inline padding. |
| Do | Provide an emptyState prop so new users see a clear prompt to start a conversation instead of a blank screen. |
| Do | Use the ghost bubble variant for AI-style responses that show rich content like code blocks or markdown without a visible boundary. |
| Don't | Don't use XDSChatSystemMessage for sender content — it has no avatar, alignment, or bubble. Use XDSChatMessage with a sender role instead. |
| Don't | Don't put long or multi-line content in a system message — keep it to a single short sentence. If you need more, use a bubble or a card. |
| Don't | Don't nest XDSChatMessage inside another XDSChatMessage — each message is a standalone article element with its own sender context. |
| Don't | Don't apply a fixed height directly on the message list — wrap it in a sized container and let the list fill with flex: 1. |
| Don't | Don't mix filled and ghost bubble variants within the same sender's messages — pick one style per side and use it consistently. |
| Don't | Don't place metadata or names on both the bubble and the message wrapper — pick one based on whether the content has a bubble boundary. |
Anatomy
| Element | Description | |
|---|---|---|
| Message area | required | Scrollable region for messages. Renders children (typically XDSChatMessageList) in a flex column that pushes content to the bottom when the list is short. |
| Frosted glass dock | required | Sticky or fixed container at the bottom with a backdrop-blur layer. Houses the scroll button and composer. |
| Scroll-to-bottom button | Appears when the user scrolls up or new messages arrive. Defaults to XDSChatLayoutScrollButton; pass null to hide or a custom element to override. | |
| Composer | required | The input area for sending messages, typically XDSChatComposer. Docked at the bottom inside the frosted glass layer. |
| Empty state | Centered placeholder shown when no messages exist. Use XDSEmptyState for a consistent look. | |
| Avatar | A sender avatar rendered beside the message. Typically XDSAvatar with size="small". Hidden for system messages. | |
| Name | Sender name above the message body. Place on the bubble when using bubbles, or on the message wrapper for raw content. | |
| Content | required | The message body — one or more XDSChatMessageBubble elements, or any free-form ReactNode like images or tool calls. |
| Metadata | Timestamp, delivery status, and footer actions below the message. Place on the last bubble or on the message wrapper. |
Import
tsimport {XDSChatTokenizedText} from '@xds/core/Chat'
Props
| Prop | Type | Description |
|---|---|---|
childrenrequired | string | The plain text message containing serialized token values. Patterns matching a token's value are replaced with badge components inline. |
tokens | XDSChatComposerToken[] | Token definitions — same type returned by trigger onSelect. Each token has a value (the string to match), label (display text), and optional variant and icon. Uses the same type as the composer input, so token definitions work for both input and display. |
Examples
Common configurations, variations, and states.ChatTokenizedText — BasicA message with @mention tokens. Each matching pattern is replaced with its display name badge.
tsx'use client';import {XDSChatTokenizedText,XDSChatMessage,XDSChatMessageBubble,XDSChatMessageList,} from '@xds/core/Chat';const tokens = [{value: '@cindy', label: '@Cindy', variant: 'blue' as const},{value: '@alex', label: '@Alex', variant: 'blue' as const},];export default function ChatTokenizedTextBasic() {return (<XDSChatMessageList><XDSChatMessage sender="system"><XDSChatMessageBubble><XDSChatTokenizedText tokens={tokens}>Assign @cindy and @alex as reviewers.</XDSChatTokenizedText></XDSChatMessageBubble></XDSChatMessage></XDSChatMessageList>);}
ChatTokenizedText — ColorsTokens with different color variants to distinguish mentions, bugs, and features. Use variant colors to create a visual taxonomy — blue for people, red for bugs, green for features.
tsx'use client';import {XDSChatTokenizedText,XDSChatMessage,XDSChatMessageBubble,XDSChatMessageList,} from '@xds/core/Chat';const mixedTokens = [{value: '@cindy', label: '@Cindy', variant: 'blue' as const},{value: '#bug', label: '#bug', variant: 'red' as const},{value: '#feat', label: '#feature', variant: 'green' as const},];export default function ChatTokenizedTextColors() {return (<XDSChatMessageList><XDSChatMessage sender="system"><XDSChatMessageBubble><XDSChatTokenizedText tokens={mixedTokens}>@cindy filed #bug and #feat for the sprint</XDSChatTokenizedText></XDSChatMessageBubble></XDSChatMessage></XDSChatMessageList>);}
Showcase source
tsx'use client';import {XDSChatTokenizedText,XDSChatMessage,XDSChatMessageBubble,XDSChatMessageList,} from '@xds/core/Chat';const mixedTokens = [{value: '@cindy', label: '@Cindy', variant: 'blue' as const},{value: '#bug', label: '#bug', variant: 'red' as const},{value: '#feat', label: '#feature', variant: 'green' as const},];export default function ChatTokenizedTextShowcase() {return (<XDSChatMessageList><XDSChatMessage sender="system"><XDSChatMessageBubble><XDSChatTokenizedText tokens={mixedTokens}>@cindy filed #bug and #feat for the sprint</XDSChatTokenizedText></XDSChatMessageBubble></XDSChatMessage></XDSChatMessageList>);}