Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(core): Chat additions — ChatReactionBar, ChatEmojiPicker, ChatUnreadDivider, ChatTypingIndicator (#3328)

David Petersen7e5db0eb3e63
diff --git a/apps/storybook/stories/ChatAdditions.stories.tsx b/apps/storybook/stories/ChatAdditions.stories.tsx
new file mode 100644
index 0000000000..69b99a9c9a
--- /dev/null
+++ b/apps/storybook/stories/ChatAdditions.stories.tsx
@@ -0,0 +1,132 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {useState} from 'react';
+import type {Meta, StoryObj} from '@storybook/react';
+import {
+ ChatMessageList,
+ ChatMessage,
+ ChatMessageBubble,
+} from '@astryxdesign/core/Chat';
+import {Button} from '@astryxdesign/core/Button';
+import {
+ ChatEmojiPicker,
+ ChatReactionBar,
+ ChatTypingIndicator,
+ ChatUnreadDivider,
+} from '@astryxdesign/lab';
+import type {ChatReaction} from '@astryxdesign/lab';
+
+const meta: Meta = {
+ title: 'Lab/ChatAdditions',
+ tags: ['autodocs'],
+ parameters: {
+ layout: 'centered',
+ },
+ decorators: [
+ Story => (
+ <div style={{width: 640, maxWidth: '100%'}}>
+ <Story />
+ </div>
+ ),
+ ],
+};
+
+export default meta;
+
+type Story = StoryObj;
+
+const INITIAL_REACTIONS: ChatReaction[] = [
+ {
+ emoji: '🎉',
+ count: 4,
+ isSelected: true,
+ label: 'You, Dana, Lee, and Mia reacted with 🎉',
+ },
+ {emoji: '👀', count: 2, label: 'Dana and Lee reacted with 👀'},
+];
+
+export const Reactions: Story = {
+ render: () => {
+ const [reactions, setReactions] = useState(INITIAL_REACTIONS);
+
+ const handleToggle = (emoji: string) => {
+ setReactions(prev =>
+ prev
+ .map(reaction =>
+ reaction.emoji === emoji
+ ? {
+ ...reaction,
+ isSelected: !reaction.isSelected,
+ count: reaction.count + (reaction.isSelected ? -1 : 1),
+ }
+ : reaction,
+ )
+ .filter(reaction => reaction.count > 0),
+ );
+ };
+
+ const handleAdd = (emoji: string) => {
+ setReactions(prev => {
+ const existing = prev.find(reaction => reaction.emoji === emoji);
+ if (existing != null) {
+ return existing.isSelected
+ ? prev
+ : prev.map(reaction =>
+ reaction.emoji === emoji
+ ? {...reaction, isSelected: true, count: reaction.count + 1}
+ : reaction,
+ );
+ }
+ return [...prev, {emoji, count: 1, isSelected: true}];
+ });
+ };
+
+ return (
+ <ChatMessageList style={{maxWidth: 600}}>
+ <ChatMessage sender="assistant">
+ <ChatMessageBubble>
+ The design review went great. Tokens are approved and we can start
+ testing the new chat affordances next sprint.
+ </ChatMessageBubble>
+ <ChatReactionBar
+ reactions={reactions}
+ onToggle={handleToggle}
+ onAdd={handleAdd}
+ />
+ </ChatMessage>
+ </ChatMessageList>
+ );
+ },
+};
+
+export const TypingAndUnread: Story = {
+ render: () => (
+ <ChatMessageList style={{maxWidth: 600}}>
+ <ChatMessage sender="user">
+ <ChatMessageBubble>
+ Sounds good. I&apos;ll take the migration notes.
+ </ChatMessageBubble>
+ </ChatMessage>
+ <ChatUnreadDivider />
+ <ChatMessage sender="assistant">
+ <ChatMessageBubble>
+ Perfect. I&apos;ve drafted the rollout checklist and shared it with
+ the team.
+ </ChatMessageBubble>
+ </ChatMessage>
+ <ChatTypingIndicator names={['Ana', 'Ben', 'Casey']} />
+ </ChatMessageList>
+ ),
+};
+
+export const EmojiPicker: Story = {
+ render: () => {
+ const [selected, setSelected] = useState('🎉');
+
+ return (
+ <ChatEmojiPicker onSelect={setSelected}>
+ <Button label={`Pick emoji ${selected}`} variant="secondary" />
+ </ChatEmojiPicker>
+ );
+ },
+};
diff --git a/packages/core/src/Chat/index.ts b/packages/core/src/Chat/index.ts
index d1cb159197..dceb0f38ef 100644
--- a/packages/core/src/Chat/index.ts
+++ b/packages/core/src/Chat/index.ts
@@ -21,10 +21,7 @@ export type {ChatSendButtonProps} from './ChatSendButton';
export {ChatComposerDrawer} from './ChatComposerDrawer';
export type {ChatComposerDrawerProps} from './ChatComposerDrawer';
-export {
- ChatComposerInput,
- ChatComposerTokenElement,
-} from './ChatComposerInput';
+export {ChatComposerInput, ChatComposerTokenElement} from './ChatComposerInput';
export type {
ChatComposerInputProps,
ChatComposerInputHandle,
diff --git a/packages/lab/src/Chat/ChatEmojiPicker.doc.mjs b/packages/lab/src/Chat/ChatEmojiPicker.doc.mjs
new file mode 100644
index 0000000000..091b449dc9
--- /dev/null
+++ b/packages/lab/src/Chat/ChatEmojiPicker.doc.mjs
@@ -0,0 +1,68 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @type {import('../../core/src/docs-types').ComponentDoc} */
+
+export const docs = {
+ name: 'ChatEmojiPicker',
+ subComponentOf: 'Chat',
+ displayName: 'Chat Emoji Picker',
+ description: 'Popover emoji grid wrapping a trigger button: a shortname filter input over an 8-column grid with arrow-key roving focus. Picking an emoji calls onSelect and closes the popover, restoring focus to the trigger. Ships with a small default emoji set; override via emojis.',
+ props: [
+ {
+ name: 'onSelect',
+ type: '(emoji: string) => void',
+ description: 'Called with the picked emoji character. The popover closes itself after selection.',
+ required: true,
+ },
+ {
+ name: 'emojis',
+ type: 'readonly {emoji: string; name: string}[]',
+ description: 'Emoji options rendered in the grid, 8 per row. name drives filtering and accessible labels.',
+ default: 'DEFAULT_CHAT_EMOJIS',
+ },
+ {
+ name: 'label',
+ type: 'string',
+ description: 'Accessible label for the popover dialog.',
+ default: "'Pick an emoji'",
+ },
+ {
+ name: 'searchLabel',
+ type: 'string',
+ description: 'Placeholder and hidden label for the filter input.',
+ default: "'Search emoji'",
+ },
+ {
+ name: 'children',
+ type: 'ReactNode',
+ description: 'Trigger element. Must contain a button; the popover wires up click handlers and ARIA automatically.',
+ required: true,
+ },
+ ],
+};
+
+export const docsZh = {
+ name: 'ChatEmojiPicker',
+ displayName: 'Chat Emoji Picker',
+ description: '包裹触发按钮的弹出层表情网格:短名过滤输入框 + 8 列网格,方向键在网格内移动焦点。选中表情会调用 onSelect 并关闭弹出层,焦点回到触发元素。内置小型默认表情集,可通过 emojis 覆盖。',
+ propDescriptions: {
+ onSelect: '以选中的表情字符调用;弹出层随后自动关闭。',
+ emojis: '网格渲染的表情选项,每行 8 个。name 用于过滤和无障碍标签。',
+ label: '弹出层对话框的无障碍标签。',
+ searchLabel: '过滤输入框的占位符和隐藏标签。',
+ children: '触发元素,必须包含一个按钮。',
+ },
+};
+
+export const docsDense = {
+ name: 'ChatEmojiPicker',
+ displayName: 'Chat Emoji Picker',
+ description: 'popover emoji grid on a trigger button; shortname filter + 8-col arrow-key nav; onSelect closes + restores focus; DEFAULT_CHAT_EMOJIS overridable',
+ propDescriptions: {
+ onSelect: '(emoji)=>void; closes popover',
+ emojis: '{emoji,name}[] grid options, 8/row; name drives filter + aria',
+ label: 'popover dialog aria label',
+ searchLabel: 'filter input placeholder + hidden label',
+ children: 'trigger element containing a button',
+ },
+};
diff --git a/packages/lab/src/Chat/ChatEmojiPicker.test.tsx b/packages/lab/src/Chat/ChatEmojiPicker.test.tsx
new file mode 100644
index 0000000000..b2195451bd
--- /dev/null
+++ b/packages/lab/src/Chat/ChatEmojiPicker.test.tsx
@@ -0,0 +1,143 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect, vi, beforeAll, afterAll} from 'vitest';
+import {render, screen, fireEvent} from '@testing-library/react';
+import {ChatEmojiPicker, DEFAULT_CHAT_EMOJIS} from './ChatEmojiPicker';
+
+// Store original matches to restore later
+const originalMatches = HTMLElement.prototype.matches;
+
+// Track popover open state per element (jsdom lacks the Popover API)
+const popoverOpenState = new WeakMap<HTMLElement, boolean>();
+
+beforeAll(() => {
+ HTMLElement.prototype.showPopover = vi.fn(function (this: HTMLElement) {
+ popoverOpenState.set(this, true);
+ const event = new Event('toggle');
+ Object.defineProperty(event, 'newState', {value: 'open'});
+ this.dispatchEvent(event);
+ });
+ HTMLElement.prototype.hidePopover = vi.fn(function (this: HTMLElement) {
+ popoverOpenState.set(this, false);
+ const event = new Event('toggle');
+ Object.defineProperty(event, 'newState', {value: 'closed'});
+ this.dispatchEvent(event);
+ });
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (HTMLElement.prototype as any).matches = function (
+ selector: string,
+ ): boolean {
+ if (selector === ':popover-open') {
+ return popoverOpenState.get(this) ?? false;
+ }
+ return originalMatches.call(this, selector);
+ };
+});
+
+afterAll(() => {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (HTMLElement.prototype as any).matches = originalMatches;
+});
+
+function renderPicker(onSelect: (emoji: string) => void = () => {}) {
+ return render(
+ <ChatEmojiPicker onSelect={onSelect}>
+ <button type="button">Open picker</button>
+ </ChatEmojiPicker>,
+ );
+}
+
+function getGridButtons(): HTMLButtonElement[] {
+ return Array.from(document.querySelectorAll('button[data-emoji]'));
+}
+
+describe('ChatEmojiPicker', () => {
+ it('renders the trigger', () => {
+ renderPicker();
+ expect(screen.getByRole('button', {name: 'Open picker'})).toBeTruthy();
+ });
+
+ it('renders the default emoji set in the grid', () => {
+ renderPicker();
+ expect(getGridButtons().length).toBe(DEFAULT_CHAT_EMOJIS.length);
+ expect(
+ screen.getByRole('button', {name: 'React with tada', hidden: true}),
+ ).toBeTruthy();
+ });
+
+ it('renders custom emojis when provided', () => {
+ render(
+ <ChatEmojiPicker
+ onSelect={() => {}}
+ emojis={[{emoji: '🦄', name: 'unicorn'}]}>
+ <button type="button">Open</button>
+ </ChatEmojiPicker>,
+ );
+ expect(getGridButtons().length).toBe(1);
+ expect(
+ screen.getByRole('button', {name: 'React with unicorn', hidden: true}),
+ ).toBeTruthy();
+ });
+
+ it('filters the grid by shortname', () => {
+ renderPicker();
+ fireEvent.change(screen.getByLabelText('Search emoji'), {
+ target: {value: 'fire'},
+ });
+ const buttons = getGridButtons();
+ expect(buttons.length).toBe(1);
+ expect(buttons[0].getAttribute('data-emoji')).toBe('🔥');
+ });
+
+ it('shows a no-match message for an empty filter result', () => {
+ renderPicker();
+ fireEvent.change(screen.getByLabelText('Search emoji'), {
+ target: {value: 'zzzz'},
+ });
+ expect(getGridButtons().length).toBe(0);
+ expect(screen.getByText(/No emoji match/)).toBeTruthy();
+ });
+
+ it('calls onSelect with the picked emoji', () => {
+ const onSelect = vi.fn();
+ renderPicker(onSelect);
+ fireEvent.click(screen.getByRole('button', {name: 'Open picker'}));
+ fireEvent.click(
+ screen.getByRole('button', {name: 'React with tada', hidden: true}),
+ );
+ expect(onSelect).toHaveBeenCalledWith('🎉');
+ });
+
+ it('clears the filter after selection', () => {
+ renderPicker();
+ fireEvent.change(screen.getByLabelText('Search emoji'), {
+ target: {value: 'fire'},
+ });
+ fireEvent.click(
+ screen.getByRole('button', {name: 'React with fire', hidden: true}),
+ );
+ expect(getGridButtons().length).toBe(DEFAULT_CHAT_EMOJIS.length);
+ });
+
+ it('moves focus right/left with arrow keys', () => {
+ renderPicker();
+ const grid = screen.getByRole('group', {name: 'Emoji', hidden: true});
+ const buttons = getGridButtons();
+ buttons[0].focus();
+ fireEvent.keyDown(grid, {key: 'ArrowRight'});
+ expect(document.activeElement).toBe(buttons[1]);
+ fireEvent.keyDown(grid, {key: 'ArrowLeft'});
+ expect(document.activeElement).toBe(buttons[0]);
+ });
+
+ it('moves focus by a row with ArrowDown/ArrowUp', () => {
+ renderPicker();
+ const grid = screen.getByRole('group', {name: 'Emoji', hidden: true});
+ const buttons = getGridButtons();
+ buttons[0].focus();
+ fireEvent.keyDown(grid, {key: 'ArrowDown'});
+ expect(document.activeElement).toBe(buttons[8]);
+ fireEvent.keyDown(grid, {key: 'ArrowUp'});
+ expect(document.activeElement).toBe(buttons[0]);
+ });
+});
diff --git a/packages/lab/src/Chat/ChatEmojiPicker.tsx b/packages/lab/src/Chat/ChatEmojiPicker.tsx
new file mode 100644
index 0000000000..efa5a7579b
--- /dev/null
+++ b/packages/lab/src/Chat/ChatEmojiPicker.tsx
@@ -0,0 +1,287 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file ChatEmojiPicker.tsx
+ * @input Uses React, StyleX, theme tokens, Popover, TextInput, useGridFocus
+ * @output Exports ChatEmojiPicker component, ChatEmojiPickerProps,
+ * ChatEmojiOption, and DEFAULT_CHAT_EMOJIS
+ * @position Popover emoji grid for chat reactions; wraps a trigger button
+ *
+ * Renders a Popover around a trigger element: a shortname filter input over
+ * a fixed 8-column emoji grid. Arrow keys move focus through the grid
+ * (left/right by one, up/down by a row) via useGridFocus; picking an emoji
+ * calls onSelect and closes the popover, which restores focus to the
+ * trigger. Ships with a small default emoji set; pass `emojis` to override.
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/lab/src/Chat/index.ts (exports)
+ * - /packages/lab/src/Chat/ChatEmojiPicker.doc.mjs
+ * - /apps/storybook/stories/ChatAdditions.stories.tsx (examples)
+ */
+
+import type {ReactNode} from 'react';
+import {useState} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {
+ colorVars,
+ spacingVars,
+ radiusVars,
+ durationVars,
+ easeVars,
+ typographyVars,
+ typeScaleVars,
+} from '@astryxdesign/core/theme/tokens.stylex';
+import type {BaseProps} from '@astryxdesign/core';
+import {mergeProps} from '@astryxdesign/core/utils';
+import {themeProps} from '@astryxdesign/core/utils';
+import {Popover} from '@astryxdesign/core/Popover';
+import {TextInput} from '@astryxdesign/core/TextInput';
+import {useGridFocus} from '@astryxdesign/core/hooks';
+
+export interface ChatEmojiOption {
+ /** The emoji character, e.g. "🎉". */
+ emoji: string;
+ /** Shortname used for filtering and accessible labels, e.g. "tada". */
+ name: string;
+}
+
+/**
+ * Small default emoji set (two grid rows) covering the common
+ * reaction vocabulary. Override via the `emojis` prop.
+ */
+export const DEFAULT_CHAT_EMOJIS: ReadonlyArray<ChatEmojiOption> = [
+ {emoji: '👍', name: 'thumbs up'},
+ {emoji: '❤️', name: 'heart'},
+ {emoji: '😂', name: 'joy'},
+ {emoji: '🎉', name: 'tada'},
+ {emoji: '😮', name: 'wow'},
+ {emoji: '😢', name: 'cry'},
+ {emoji: '🔥', name: 'fire'},
+ {emoji: '👀', name: 'eyes'},
+ {emoji: '✅', name: 'check'},
+ {emoji: '🙏', name: 'pray'},
+ {emoji: '💯', name: 'hundred'},
+ {emoji: '🚀', name: 'rocket'},
+ {emoji: '😍', name: 'heart eyes'},
+ {emoji: '🤔', name: 'thinking'},
+ {emoji: '👋', name: 'wave'},
+ {emoji: '⭐', name: 'star'},
+];
+
+const GRID_COLUMNS = 8;
+
+export interface ChatEmojiPickerProps extends Omit<
+ BaseProps<HTMLDivElement>,
+ 'onSelect'
+> {
+ /** Ref forwarded to the popover panel element */
+ ref?: React.Ref<HTMLDivElement>;
+
+ /**
+ * Called with the picked emoji character.
+ * The popover closes itself after selection.
+ */
+ onSelect: (emoji: string) => void;
+
+ /**
+ * Emoji options rendered in the grid (8 per row).
+ * @default DEFAULT_CHAT_EMOJIS
+ */
+ emojis?: ReadonlyArray<ChatEmojiOption>;
+
+ /**
+ * Accessible label for the popover dialog.
+ * @default 'Pick an emoji'
+ */
+ label?: string;
+
+ /**
+ * Placeholder and hidden label for the filter input.
+ * @default 'Search emoji'
+ */
+ searchLabel?: string;
+
+ /**
+ * Trigger element — must contain a `<button>` (Popover wires it up).
+ */
+ children: ReactNode;
+
+ /** Test ID for the popover content. */
+ 'data-testid'?: string;
+}
+
+// =============================================================================
+// Styles
+// =============================================================================
+
+const styles = stylex.create({
+ panel: {
+ display: 'flex',
+ flexDirection: 'column',
+ gap: spacingVars['--spacing-2'],
+ width: GRID_COLUMNS * 34 + 8,
+ boxSizing: 'border-box',
+ },
+ grid: {
+ display: 'grid',
+ gridTemplateColumns: `repeat(${GRID_COLUMNS}, 1fr)`,
+ gap: spacingVars['--spacing-0-5'],
+ },
+ cell: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: 32,
+ height: 32,
+ borderRadius: radiusVars['--radius-inner'],
+ borderStyle: 'none',
+ padding: 0,
+ backgroundColor: {
+ default: 'transparent',
+ ':hover': {
+ default: 'transparent',
+ '@media (hover: hover)': colorVars['--color-overlay-hover'],
+ },
+ },
+ cursor: 'pointer',
+ fontSize: 18,
+ lineHeight: typeScaleVars['--text-body-leading'],
+ outline: {
+ default: 'none',
+ ':focus-visible': `2px solid ${colorVars['--color-accent']}`,
+ },
+ outlineOffset: -2,
+ transitionProperty: 'background-color',
+ transitionDuration: {
+ default: durationVars['--duration-fast'],
+ '@media (prefers-reduced-motion: reduce)': '0s',
+ },
+ transitionTimingFunction: easeVars['--ease-standard'],
+ },
+ empty: {
+ paddingBlock: spacingVars['--spacing-2'],
+ paddingInline: spacingVars['--spacing-1'],
+ fontFamily: typographyVars['--font-family-body'],
+ fontSize: typeScaleVars['--text-supporting-size'],
+ color: colorVars['--color-text-secondary'],
+ },
+});
+
+// =============================================================================
+// Component
+// =============================================================================
+
+/**
+ * Popover emoji grid with shortname filtering and arrow-key navigation.
+ *
+ * Wraps its trigger button in a Popover. Typing in the filter input narrows
+ * the grid by shortname; arrow keys move focus between emoji; picking one
+ * calls `onSelect` and closes the popover (focus returns to the trigger).
+ *
+ * @example
+ * ```
+ * <ChatEmojiPicker onSelect={(emoji) => addReaction(emoji)}>
+ * <button type="button" aria-label="Add reaction">🙂</button>
+ * </ChatEmojiPicker>
+ * ```
+ */
+export function ChatEmojiPicker({
+ onSelect,
+ emojis = DEFAULT_CHAT_EMOJIS,
+ label = 'Pick an emoji',
+ searchLabel = 'Search emoji',
+ children,
+ xstyle,
+ className,
+ style: styleProp,
+ 'data-testid': testId,
+ ref,
+}: ChatEmojiPickerProps) {
+ const [isOpen, setIsOpen] = useState(false);
+ const [query, setQuery] = useState('');
+ const {gridRef, handleKeyDown} = useGridFocus<HTMLDivElement>({
+ columns: GRID_COLUMNS,
+ });
+
+ const trimmed = query.trim().toLowerCase();
+ const visible =
+ trimmed === ''
+ ? emojis
+ : emojis.filter(
+ option =>
+ option.name.toLowerCase().includes(trimmed) ||
+ option.emoji === trimmed,
+ );
+
+ const handleOpenChange = (open: boolean) => {
+ setIsOpen(open);
+ if (!open) {
+ setQuery('');
+ }
+ };
+
+ const handleSelect = (emoji: string) => {
+ onSelect(emoji);
+ handleOpenChange(false);
+ };
+
+ return (
+ <Popover
+ isOpen={isOpen}
+ onOpenChange={handleOpenChange}
+ label={label}
+ placement="below"
+ alignment="start"
+ data-testid={testId}
+ content={
+ <div
+ ref={ref}
+ {...mergeProps(
+ themeProps('chat-emoji-picker'),
+ stylex.props(styles.panel, xstyle),
+ className,
+ styleProp,
+ )}>
+ <TextInput
+ label={searchLabel}
+ isLabelHidden
+ size="sm"
+ placeholder={searchLabel}
+ value={query}
+ onChange={setQuery}
+ hasClear
+ />
+ {visible.length === 0 ? (
+ <div {...stylex.props(styles.empty)}>
+ No emoji match “{query.trim()}”.
+ </div>
+ ) : (
+ <div
+ ref={gridRef}
+ role="group"
+ aria-label="Emoji"
+ onKeyDown={handleKeyDown}
+ {...stylex.props(styles.grid)}>
+ {visible.map(option => (
+ <button
+ key={option.emoji}
+ type="button"
+ data-emoji={option.emoji}
+ aria-label={`React with ${option.name}`}
+ onClick={() => handleSelect(option.emoji)}
+ {...stylex.props(styles.cell)}>
+ <span aria-hidden="true">{option.emoji}</span>
+ </button>
+ ))}
+ </div>
+ )}
+ </div>
+ }>
+ {children}
+ </Popover>
+ );
+}
+
+ChatEmojiPicker.displayName = 'ChatEmojiPicker';
diff --git a/packages/lab/src/Chat/ChatReactionBar.doc.mjs b/packages/lab/src/Chat/ChatReactionBar.doc.mjs
new file mode 100644
index 0000000000..1d599eda77
--- /dev/null
+++ b/packages/lab/src/Chat/ChatReactionBar.doc.mjs
@@ -0,0 +1,73 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @type {import('../../core/src/docs-types').ComponentDoc} */
+
+export const docs = {
+ name: 'ChatReactionBar',
+ subComponentOf: 'Chat',
+ displayName: 'Chat Reaction Bar',
+ description: 'Row of emoji reaction pills under a chat message. Each pill shows an emoji and count; the current user’s own reactions get an accent tint and aria-pressed. Provide onAdd to render a trailing add-reaction button that opens a ChatEmojiPicker popover.',
+ props: [
+ {
+ name: 'reactions',
+ type: '{emoji: string; count: number; isSelected?: boolean; label?: string}[]',
+ description: 'Reactions to render, in display order. isSelected marks the current user’s own reactions (accent tint + aria-pressed). label is a human-readable description like "Ana and Dana reacted with 🎉", used as the pill tooltip and accessible label.',
+ required: true,
+ },
+ {
+ name: 'onToggle',
+ type: '(emoji: string) => void',
+ description: 'Called with the pill’s emoji when the user toggles a reaction on or off.',
+ },
+ {
+ name: 'onAdd',
+ type: '(emoji: string) => void',
+ description: 'Called with the picked emoji when the user adds a reaction from the emoji picker. The trailing add-reaction button renders only when provided.',
+ },
+ {
+ name: 'emojis',
+ type: 'readonly ChatEmojiOption[]',
+ description: 'Emoji options for the add-reaction picker. Defaults to DEFAULT_CHAT_EMOJIS.',
+ },
+ {
+ name: 'addLabel',
+ type: 'string',
+ description: 'Accessible label for the add-reaction button and picker dialog.',
+ default: "'Add reaction'",
+ },
+ {
+ name: 'label',
+ type: 'string',
+ description: 'Accessible label for the reaction group.',
+ default: "'Reactions'",
+ },
+ ],
+};
+
+export const docsZh = {
+ name: 'ChatReactionBar',
+ displayName: 'Chat Reaction Bar',
+ description: '聊天消息下方的表情回应胶囊行。每个胶囊显示表情和数量;当前用户自己的回应带有强调色和 aria-pressed。提供 onAdd 会渲染末尾的添加回应按钮,打开 ChatEmojiPicker 弹出层。',
+ propDescriptions: {
+ reactions: '按显示顺序渲染的回应列表。isSelected 标记当前用户自己的回应(强调色 + aria-pressed)。label 是人类可读的描述,用作胶囊的提示与无障碍标签。',
+ onToggle: '用户切换回应时以该表情调用。',
+ onAdd: '用户从表情选择器添加回应时以所选表情调用。仅在提供时渲染末尾的添加按钮。',
+ emojis: '添加回应选择器的表情选项,默认 DEFAULT_CHAT_EMOJIS。',
+ addLabel: '添加回应按钮与选择器对话框的无障碍标签。',
+ label: '回应组的无障碍标签。',
+ },
+};
+
+export const docsDense = {
+ name: 'ChatReactionBar',
+ displayName: 'Chat Reaction Bar',
+ description: 'emoji reaction pills under a message; own reactions accent-tinted w/ aria-pressed; onAdd renders trailing add button opening ChatEmojiPicker popover',
+ propDescriptions: {
+ reactions: '{emoji,count,isSelected?,label?}[]; label doubles as tooltip + aria label',
+ onToggle: '(emoji)=>void on pill click',
+ onAdd: '(emoji)=>void from picker; enables add button',
+ emojis: 'picker option override; default DEFAULT_CHAT_EMOJIS',
+ addLabel: 'add button + picker dialog label',
+ label: 'group aria label',
+ },
+};
diff --git a/packages/lab/src/Chat/ChatReactionBar.test.tsx b/packages/lab/src/Chat/ChatReactionBar.test.tsx
new file mode 100644
index 0000000000..a13c8c2641
--- /dev/null
+++ b/packages/lab/src/Chat/ChatReactionBar.test.tsx
@@ -0,0 +1,124 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect, vi, beforeAll, afterAll} from 'vitest';
+import {render, screen, fireEvent} from '@testing-library/react';
+import {ChatReactionBar} from './ChatReactionBar';
+
+// Store original matches to restore later
+const originalMatches = HTMLElement.prototype.matches;
+
+// Track popover open state per element (jsdom lacks the Popover API)
+const popoverOpenState = new WeakMap<HTMLElement, boolean>();
+
+beforeAll(() => {
+ HTMLElement.prototype.showPopover = vi.fn(function (this: HTMLElement) {
+ popoverOpenState.set(this, true);
+ const event = new Event('toggle');
+ Object.defineProperty(event, 'newState', {value: 'open'});
+ this.dispatchEvent(event);
+ });
+ HTMLElement.prototype.hidePopover = vi.fn(function (this: HTMLElement) {
+ popoverOpenState.set(this, false);
+ const event = new Event('toggle');
+ Object.defineProperty(event, 'newState', {value: 'closed'});
+ this.dispatchEvent(event);
+ });
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (HTMLElement.prototype as any).matches = function (
+ selector: string,
+ ): boolean {
+ if (selector === ':popover-open') {
+ return popoverOpenState.get(this) ?? false;
+ }
+ return originalMatches.call(this, selector);
+ };
+});
+
+afterAll(() => {
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (HTMLElement.prototype as any).matches = originalMatches;
+});
+
+const REACTIONS = [
+ {
+ emoji: '🎉',
+ count: 4,
+ isSelected: true,
+ label: 'You and Dana reacted with 🎉',
+ },
+ {emoji: '👀', count: 2},
+];
+
+describe('ChatReactionBar', () => {
+ it('renders a pill per reaction with its count', () => {
+ render(<ChatReactionBar reactions={REACTIONS} />);
+ expect(
+ screen.getByRole('button', {name: 'You and Dana reacted with 🎉'}),
+ ).toBeTruthy();
+ expect(
+ screen.getByRole('button', {name: '2 reactions with 👀'}),
+ ).toBeTruthy();
+ expect(screen.getByText('4')).toBeTruthy();
+ expect(screen.getByText('2')).toBeTruthy();
+ });
+
+ it('reflects isSelected via aria-pressed', () => {
+ render(<ChatReactionBar reactions={REACTIONS} />);
+ const selected = screen.getByRole('button', {
+ name: 'You and Dana reacted with 🎉',
+ });
+ const unselected = screen.getByRole('button', {
+ name: '2 reactions with 👀',
+ });
+ expect(selected.getAttribute('aria-pressed')).toBe('true');
+ expect(unselected.getAttribute('aria-pressed')).toBe('false');
+ });
+
+ it('uses a singular label for a single reaction', () => {
+ render(<ChatReactionBar reactions={[{emoji: '🔥', count: 1}]} />);
+ expect(
+ screen.getByRole('button', {name: '1 reaction with 🔥'}),
+ ).toBeTruthy();
+ });
+
+ it('calls onToggle with the pill emoji', () => {
+ const onToggle = vi.fn();
+ render(<ChatReactionBar reactions={REACTIONS} onToggle={onToggle} />);
+ fireEvent.click(screen.getByRole('button', {name: '2 reactions with 👀'}));
+ expect(onToggle).toHaveBeenCalledWith('👀');
+ });
+
+ it('renders as a labeled group', () => {
+ render(<ChatReactionBar reactions={REACTIONS} data-testid="bar" />);
+ const bar = screen.getByTestId('bar');
+ expect(bar.getAttribute('role')).toBe('group');
+ expect(bar.getAttribute('aria-label')).toBe('Reactions');
+ });
+
+ it('hides the add button when onAdd is not provided', () => {
+ render(<ChatReactionBar reactions={REACTIONS} />);
+ expect(screen.queryByRole('button', {name: 'Add reaction'})).toBeNull();
+ });
+
+ it('shows the add button when onAdd is provided', () => {
+ render(<ChatReactionBar reactions={REACTIONS} onAdd={() => {}} />);
+ expect(screen.getByRole('button', {name: 'Add reaction'})).toBeTruthy();
+ });
+
+ it('calls onAdd with the emoji picked from the picker', () => {
+ const onAdd = vi.fn();
+ render(<ChatReactionBar reactions={REACTIONS} onAdd={onAdd} />);
+ fireEvent.click(screen.getByRole('button', {name: 'Add reaction'}));
+ fireEvent.click(
+ screen.getByRole('button', {name: 'React with fire', hidden: true}),
+ );
+ expect(onAdd).toHaveBeenCalledWith('🔥');
+ });
+
+ it('applies the stable class name', () => {
+ render(<ChatReactionBar reactions={REACTIONS} data-testid="bar" />);
+ expect(screen.getByTestId('bar').className).toContain(
+ 'astryx-chat-reaction-bar',
+ );
+ });
+});
diff --git a/packages/lab/src/Chat/ChatReactionBar.tsx b/packages/lab/src/Chat/ChatReactionBar.tsx
new file mode 100644
index 0000000000..0c42a77a7d
--- /dev/null
+++ b/packages/lab/src/Chat/ChatReactionBar.tsx
@@ -0,0 +1,290 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file ChatReactionBar.tsx
+ * @input Uses React, StyleX, theme tokens, Tooltip, ChatEmojiPicker
+ * @output Exports ChatReactionBar component, ChatReactionBarProps, ChatReaction
+ * @position Row of emoji reaction pills under a chat message
+ *
+ * Renders reaction pills (emoji + count) with a pressed state for the
+ * current user's own reactions, optional tooltips listing reactors, and an
+ * optional trailing add-reaction button that opens a ChatEmojiPicker
+ * popover. Data flows in via `reactions`; toggles flow out via `onToggle`
+ * and new reactions via `onAdd`.
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/lab/src/Chat/index.ts (exports)
+ * - /packages/lab/src/Chat/ChatReactionBar.doc.mjs
+ * - /apps/storybook/stories/ChatAdditions.stories.tsx (examples)
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import {
+ colorVars,
+ spacingVars,
+ radiusVars,
+ durationVars,
+ easeVars,
+ typographyVars,
+ typeScaleVars,
+ fontWeightVars,
+} from '@astryxdesign/core/theme/tokens.stylex';
+import type {BaseProps} from '@astryxdesign/core';
+import {mergeProps} from '@astryxdesign/core/utils';
+import {themeProps} from '@astryxdesign/core/utils';
+import {Tooltip} from '@astryxdesign/core/Tooltip';
+import {ChatEmojiPicker} from './ChatEmojiPicker';
+import type {ChatEmojiOption} from './ChatEmojiPicker';
+
+export interface ChatReaction {
+ /** The emoji character, e.g. "🎉". */
+ emoji: string;
+ /** Number of people who reacted with this emoji. */
+ count: number;
+ /**
+ * Whether the current user has reacted — accent border, tinted
+ * background, and `aria-pressed="true"` on the pill.
+ * @default false
+ */
+ isSelected?: boolean;
+ /**
+ * Human-readable description used as the pill's tooltip and accessible
+ * label, e.g. "Ana and Dana reacted with 🎉". Falls back to a count-based
+ * label when omitted.
+ */
+ label?: string;
+}
+
+export interface ChatReactionBarProps extends Omit<
+ BaseProps<HTMLDivElement>,
+ 'onToggle'
+> {
+ /** Ref forwarded to the root element */
+ ref?: React.Ref<HTMLDivElement>;
+
+ /** Reactions to render, in display order. */
+ reactions: ChatReaction[];
+
+ /** Called with the pill's emoji when the user toggles a reaction. */
+ onToggle?: (emoji: string) => void;
+
+ /**
+ * Called with the picked emoji when the user adds a reaction from the
+ * emoji picker. The trailing add-reaction button renders only when
+ * this is provided.
+ */
+ onAdd?: (emoji: string) => void;
+
+ /**
+ * Emoji options for the add-reaction picker.
+ * @default DEFAULT_CHAT_EMOJIS
+ */
+ emojis?: ReadonlyArray<ChatEmojiOption>;
+
+ /**
+ * Accessible label for the add-reaction button.
+ * @default 'Add reaction'
+ */
+ addLabel?: string;
+
+ /**
+ * Accessible label for the reaction group.
+ * @default 'Reactions'
+ */
+ label?: string;
+}
+
+// =============================================================================
+// Styles
+// =============================================================================
+
+const styles = stylex.create({
+ root: {
+ display: 'flex',
+ flexWrap: 'wrap',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-1'],
+ },
+ pill: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-1'],
+ height: 24,
+ paddingInline: spacingVars['--spacing-2'],
+ borderRadius: radiusVars['--radius-full'],
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: {
+ default: 'transparent',
+ ':hover': {
+ default: 'transparent',
+ '@media (hover: hover)': colorVars['--color-border-emphasized'],
+ },
+ },
+ backgroundColor: colorVars['--color-background-muted'],
+ cursor: 'pointer',
+ fontFamily: typographyVars['--font-family-body'],
+ boxSizing: 'border-box',
+ transitionProperty: 'border-color, background-color',
+ transitionDuration: {
+ default: durationVars['--duration-fast'],
+ '@media (prefers-reduced-motion: reduce)': '0s',
+ },
+ transitionTimingFunction: easeVars['--ease-standard'],
+ },
+ pillSelected: {
+ backgroundColor: colorVars['--color-accent-muted'],
+ borderColor: {
+ default: colorVars['--color-accent'],
+ ':hover': {
+ default: colorVars['--color-accent'],
+ '@media (hover: hover)': colorVars['--color-accent'],
+ },
+ },
+ },
+ emoji: {
+ fontSize: typeScaleVars['--text-body-size'],
+ lineHeight: typeScaleVars['--text-body-leading'],
+ },
+ count: {
+ fontSize: typeScaleVars['--text-supporting-size'],
+ fontWeight: fontWeightVars['--font-weight-medium'],
+ color: colorVars['--color-text-secondary'],
+ fontVariantNumeric: 'tabular-nums',
+ lineHeight: typeScaleVars['--text-supporting-leading'],
+ },
+ countSelected: {
+ color: colorVars['--color-text-accent'],
+ fontWeight: fontWeightVars['--font-weight-semibold'],
+ },
+ addButton: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: 32,
+ height: 24,
+ borderRadius: radiusVars['--radius-full'],
+ borderWidth: 1,
+ borderStyle: 'solid',
+ borderColor: {
+ default: 'transparent',
+ ':hover': {
+ default: 'transparent',
+ '@media (hover: hover)': colorVars['--color-border-emphasized'],
+ },
+ },
+ backgroundColor: colorVars['--color-background-muted'],
+ color: colorVars['--color-icon-secondary'],
+ cursor: 'pointer',
+ boxSizing: 'border-box',
+ fontSize: 15,
+ lineHeight: typeScaleVars['--text-supporting-leading'],
+ padding: 0,
+ },
+});
+
+function pillLabel(reaction: ChatReaction): string {
+ if (reaction.label != null) {
+ return reaction.label;
+ }
+ const noun = reaction.count === 1 ? 'reaction' : 'reactions';
+ return `${reaction.count} ${noun} with ${reaction.emoji}`;
+}
+
+// =============================================================================
+// Component
+// =============================================================================
+
+/**
+ * Row of emoji reaction pills under a chat message.
+ *
+ * Each pill shows an emoji and count; the current user's own reactions get
+ * an accent tint and `aria-pressed`. Provide `onAdd` to render a trailing
+ * add-reaction button that opens a ChatEmojiPicker popover.
+ *
+ * @example
+ * ```
+ * <ChatReactionBar
+ * reactions={[
+ * {emoji: '🎉', count: 4, isSelected: true, label: 'You and Dana reacted with 🎉'},
+ * {emoji: '👀', count: 2},
+ * ]}
+ * onToggle={(emoji) => toggleReaction(emoji)}
+ * onAdd={(emoji) => addReaction(emoji)}
+ * />
+ * ```
+ */
+export function ChatReactionBar({
+ reactions,
+ onToggle,
+ onAdd,
+ emojis,
+ addLabel = 'Add reaction',
+ label = 'Reactions',
+ xstyle,
+ className,
+ style: styleProp,
+ 'data-testid': testId,
+ ref,
+}: ChatReactionBarProps) {
+ return (
+ <div
+ ref={ref}
+ role="group"
+ aria-label={label}
+ data-testid={testId}
+ {...mergeProps(
+ themeProps('chat-reaction-bar'),
+ stylex.props(styles.root, xstyle),
+ className,
+ styleProp,
+ )}>
+ {reactions.map(reaction => {
+ const isSelected = reaction.isSelected === true;
+ const pill = (
+ <button
+ key={reaction.emoji}
+ type="button"
+ aria-pressed={isSelected}
+ aria-label={pillLabel(reaction)}
+ onClick={() => onToggle?.(reaction.emoji)}
+ {...stylex.props(styles.pill, isSelected && styles.pillSelected)}>
+ <span aria-hidden="true" {...stylex.props(styles.emoji)}>
+ {reaction.emoji}
+ </span>
+ <span
+ {...stylex.props(
+ styles.count,
+ isSelected && styles.countSelected,
+ )}>
+ {reaction.count}
+ </span>
+ </button>
+ );
+ return reaction.label != null ? (
+ <Tooltip key={reaction.emoji} content={reaction.label}>
+ {pill}
+ </Tooltip>
+ ) : (
+ pill
+ );
+ })}
+ {onAdd != null && (
+ <ChatEmojiPicker emojis={emojis} onSelect={onAdd} label={addLabel}>
+ <Tooltip content={addLabel}>
+ <button
+ type="button"
+ aria-label={addLabel}
+ {...stylex.props(styles.addButton)}>
+ +
+ </button>
+ </Tooltip>
+ </ChatEmojiPicker>
+ )}
+ </div>
+ );
+}
+
+ChatReactionBar.displayName = 'ChatReactionBar';
diff --git a/packages/lab/src/Chat/ChatTypingIndicator.doc.mjs b/packages/lab/src/Chat/ChatTypingIndicator.doc.mjs
new file mode 100644
index 0000000000..14447b1419
--- /dev/null
+++ b/packages/lab/src/Chat/ChatTypingIndicator.doc.mjs
@@ -0,0 +1,35 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @type {import('../../core/src/docs-types').ComponentDoc} */
+
+export const docs = {
+ name: 'ChatTypingIndicator',
+ subComponentOf: 'Chat',
+ displayName: 'Chat Typing Indicator',
+ description: 'Animated three-dot typing hint with a grammar-aware label: "Ana is typing…", "Ana and Ben are typing…", or "Ana and 2 others are typing…". Dots bounce with staggered stylex.keyframes delays, disabled under prefers-reduced-motion; the label is announced politely via role="status".',
+ props: [
+ {
+ name: 'names',
+ type: 'string[]',
+ description: 'Names of people currently typing. One name renders "is typing", two render both names, more collapse to "and N others". When omitted or empty, only the animated dots render.',
+ },
+ ],
+};
+
+export const docsZh = {
+ name: 'ChatTypingIndicator',
+ displayName: 'Chat Typing Indicator',
+ description: '带语法感知标签的三点跳动输入提示:"Ana is typing…"、"Ana and Ben are typing…" 或 "Ana and 2 others are typing…"。圆点用 stylex.keyframes 交错跳动,prefers-reduced-motion 下禁用;标签通过 role="status" 礼貌播报。',
+ propDescriptions: {
+ names: '正在输入的人名。一个名字渲染 "is typing",两个渲染双名,更多折叠为 "and N others"。省略或为空时仅渲染动画圆点。',
+ },
+};
+
+export const docsDense = {
+ name: 'ChatTypingIndicator',
+ displayName: 'Chat Typing Indicator',
+ description: 'bouncing three-dot typing hint; label grammar 1/2/N names; reduced-motion safe keyframes; role=status polite announce; dots-only when names empty',
+ propDescriptions: {
+ names: "string[]; 1='X is typing', 2='X and Y', 3+='X and N others'; empty=dots only",
+ },
+};
diff --git a/packages/lab/src/Chat/ChatTypingIndicator.test.tsx b/packages/lab/src/Chat/ChatTypingIndicator.test.tsx
new file mode 100644
index 0000000000..518b730ff8
--- /dev/null
+++ b/packages/lab/src/Chat/ChatTypingIndicator.test.tsx
@@ -0,0 +1,48 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect} from 'vitest';
+import {render, screen} from '@testing-library/react';
+import {ChatTypingIndicator} from './ChatTypingIndicator';
+
+describe('ChatTypingIndicator', () => {
+ it('renders "X is typing…" for one name', () => {
+ render(<ChatTypingIndicator names={['Ana']} />);
+ expect(screen.getByText('Ana is typing…')).toBeTruthy();
+ });
+
+ it('renders both names for two people', () => {
+ render(<ChatTypingIndicator names={['Ana', 'Ben']} />);
+ expect(screen.getByText('Ana and Ben are typing…')).toBeTruthy();
+ });
+
+ it('collapses three or more names to "and N others"', () => {
+ render(<ChatTypingIndicator names={['Ana', 'Ben', 'Casey']} />);
+ expect(screen.getByText('Ana and 2 others are typing…')).toBeTruthy();
+ });
+
+ it('renders dots only when names is empty', () => {
+ render(<ChatTypingIndicator names={[]} data-testid="typing" />);
+ const root = screen.getByTestId('typing');
+ expect(root.textContent).toBe('');
+ expect(root.querySelector('[aria-hidden="true"]')).toBeTruthy();
+ });
+
+ it('renders dots only when names is omitted', () => {
+ render(<ChatTypingIndicator data-testid="typing" />);
+ expect(screen.getByTestId('typing').textContent).toBe('');
+ });
+
+ it('is a polite live region', () => {
+ render(<ChatTypingIndicator names={['Ana']} data-testid="typing" />);
+ const root = screen.getByTestId('typing');
+ expect(root.getAttribute('role')).toBe('status');
+ expect(root.getAttribute('aria-live')).toBe('polite');
+ });
+
+ it('applies the stable class name', () => {
+ render(<ChatTypingIndicator names={['Ana']} data-testid="typing" />);
+ expect(screen.getByTestId('typing').className).toContain(
+ 'astryx-chat-typing-indicator',
+ );
+ });
+});
diff --git a/packages/lab/src/Chat/ChatTypingIndicator.tsx b/packages/lab/src/Chat/ChatTypingIndicator.tsx
new file mode 100644
index 0000000000..f2098c80ad
--- /dev/null
+++ b/packages/lab/src/Chat/ChatTypingIndicator.tsx
@@ -0,0 +1,158 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file ChatTypingIndicator.tsx
+ * @input Uses React, StyleX (keyframes), theme tokens
+ * @output Exports ChatTypingIndicator component and ChatTypingIndicatorProps
+ * @position Animated "X is typing…" hint above a chat composer
+ *
+ * Three staggered bouncing dots (stylex.keyframes, reduced-motion safe)
+ * with a grammar-aware label: "Ana is typing…", "Ana and Ben are typing…",
+ * or "Ana and 2 others are typing…". Announced politely via role="status".
+ * Renders dots only when no names are provided.
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/lab/src/Chat/index.ts (exports)
+ * - /packages/lab/src/Chat/ChatTypingIndicator.doc.mjs
+ * - /apps/storybook/stories/ChatAdditions.stories.tsx (examples)
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import {
+ colorVars,
+ spacingVars,
+ radiusVars,
+ durationVars,
+ typographyVars,
+ typeScaleVars,
+} from '@astryxdesign/core/theme/tokens.stylex';
+import type {BaseProps} from '@astryxdesign/core';
+import {mergeProps} from '@astryxdesign/core/utils';
+import {themeProps} from '@astryxdesign/core/utils';
+
+export interface ChatTypingIndicatorProps extends BaseProps<HTMLDivElement> {
+ /** Ref forwarded to the root element */
+ ref?: React.Ref<HTMLDivElement>;
+
+ /**
+ * Names of people currently typing. Drives the label:
+ * one name → "Ana is typing…", two → "Ana and Ben are typing…",
+ * more → "Ana and 2 others are typing…". When omitted or empty,
+ * only the animated dots render.
+ */
+ names?: string[];
+}
+
+// =============================================================================
+// Styles
+// =============================================================================
+
+const bounceKeyframes = stylex.keyframes({
+ '0%': {transform: 'translateY(0)', opacity: 0.35},
+ '30%': {transform: 'translateY(-3px)', opacity: 1},
+ '60%': {transform: 'translateY(0)', opacity: 0.35},
+ '100%': {transform: 'translateY(0)', opacity: 0.35},
+});
+
+const styles = stylex.create({
+ root: {
+ display: 'flex',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-2'],
+ minHeight: 20,
+ },
+ dots: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-0-5'],
+ },
+ dot: {
+ width: 5,
+ height: 5,
+ borderRadius: radiusVars['--radius-full'],
+ backgroundColor: colorVars['--color-icon-secondary'],
+ animationName: bounceKeyframes,
+ animationDuration: durationVars['--duration-slow'],
+ animationIterationCount: 'infinite',
+ animationTimingFunction: 'ease-in-out',
+ '@media (prefers-reduced-motion: reduce)': {
+ animationName: 'none',
+ },
+ },
+ dot2: {
+ animationDelay: '160ms',
+ },
+ dot3: {
+ animationDelay: '320ms',
+ },
+ label: {
+ fontFamily: typographyVars['--font-family-body'],
+ fontSize: typeScaleVars['--text-supporting-size'],
+ color: colorVars['--color-text-secondary'],
+ },
+});
+
+function typingLabel(names: string[] | undefined): string | null {
+ if (names == null || names.length === 0) {
+ return null;
+ }
+ if (names.length === 1) {
+ return `${names[0]} is typing…`;
+ }
+ if (names.length === 2) {
+ return `${names[0]} and ${names[1]} are typing…`;
+ }
+ return `${names[0]} and ${names.length - 1} others are typing…`;
+}
+
+// =============================================================================
+// Component
+// =============================================================================
+
+/**
+ * Animated three-dot typing hint with a name-aware label.
+ *
+ * The dots bounce with staggered delays (disabled under
+ * prefers-reduced-motion) and the label is announced politely to
+ * screen readers via role="status".
+ *
+ * @example
+ * ```
+ * <ChatTypingIndicator names={['Ana']} />
+ * <ChatTypingIndicator names={['Ana', 'Ben', 'Casey']} />
+ * ```
+ */
+export function ChatTypingIndicator({
+ names,
+ xstyle,
+ className,
+ style: styleProp,
+ 'data-testid': testId,
+ ref,
+}: ChatTypingIndicatorProps) {
+ const label = typingLabel(names);
+ return (
+ <div
+ ref={ref}
+ role="status"
+ aria-live="polite"
+ data-testid={testId}
+ {...mergeProps(
+ themeProps('chat-typing-indicator'),
+ stylex.props(styles.root, xstyle),
+ className,
+ styleProp,
+ )}>
+ <span aria-hidden="true" {...stylex.props(styles.dots)}>
+ <span {...stylex.props(styles.dot)} />
+ <span {...stylex.props(styles.dot, styles.dot2)} />
+ <span {...stylex.props(styles.dot, styles.dot3)} />
+ </span>
+ {label != null && <span {...stylex.props(styles.label)}>{label}</span>}
+ </div>
+ );
+}
+
+ChatTypingIndicator.displayName = 'ChatTypingIndicator';
diff --git a/packages/lab/src/Chat/ChatUnreadDivider.doc.mjs b/packages/lab/src/Chat/ChatUnreadDivider.doc.mjs
new file mode 100644
index 0000000000..9da63321f6
--- /dev/null
+++ b/packages/lab/src/Chat/ChatUnreadDivider.doc.mjs
@@ -0,0 +1,36 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @type {import('../../core/src/docs-types').ComponentDoc} */
+
+export const docs = {
+ name: 'ChatUnreadDivider',
+ subComponentOf: 'Chat',
+ displayName: 'Chat Unread Divider',
+ description: 'Error-colored rule with a trailing label marking where unread messages begin in a chat thread. Rendered as an aria separator with an accessible label. Distinct from ChatSystemMessage’s divider variant, which is for neutral date breaks.',
+ props: [
+ {
+ name: 'label',
+ type: 'string',
+ description: 'Divider label shown at the end of the rule and used in the accessible name ("New messages below").',
+ default: "'New'",
+ },
+ ],
+};
+
+export const docsZh = {
+ name: 'ChatUnreadDivider',
+ displayName: 'Chat Unread Divider',
+ description: '错误色横线加末尾标签,标记聊天线程中未读消息的起点。渲染为带无障碍标签的 aria separator。与 ChatSystemMessage 的 divider 变体不同,后者用于中性的日期分隔。',
+ propDescriptions: {
+ label: '横线末尾显示的标签,同时用于无障碍名称。',
+ },
+};
+
+export const docsDense = {
+ name: 'ChatUnreadDivider',
+ displayName: 'Chat Unread Divider',
+ description: 'error-colored rule + trailing label marking first unread msg; aria separator; use ChatSystemMessage divider for neutral date breaks',
+ propDescriptions: {
+ label: "trailing label + aria name; default 'New'",
+ },
+};
diff --git a/packages/lab/src/Chat/ChatUnreadDivider.test.tsx b/packages/lab/src/Chat/ChatUnreadDivider.test.tsx
new file mode 100644
index 0000000000..eaa5504fa0
--- /dev/null
+++ b/packages/lab/src/Chat/ChatUnreadDivider.test.tsx
@@ -0,0 +1,35 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect} from 'vitest';
+import {render, screen} from '@testing-library/react';
+import {ChatUnreadDivider} from './ChatUnreadDivider';
+
+describe('ChatUnreadDivider', () => {
+ it('renders a separator', () => {
+ render(<ChatUnreadDivider />);
+ expect(screen.getByRole('separator')).toBeTruthy();
+ });
+
+ it('shows the default label', () => {
+ render(<ChatUnreadDivider />);
+ expect(screen.getByText('New')).toBeTruthy();
+ expect(screen.getByRole('separator').getAttribute('aria-label')).toBe(
+ 'New messages below',
+ );
+ });
+
+ it('shows a custom label', () => {
+ render(<ChatUnreadDivider label="Unread" />);
+ expect(screen.getByText('Unread')).toBeTruthy();
+ expect(screen.getByRole('separator').getAttribute('aria-label')).toBe(
+ 'Unread messages below',
+ );
+ });
+
+ it('applies the stable class name', () => {
+ render(<ChatUnreadDivider data-testid="divider" />);
+ expect(screen.getByTestId('divider').className).toContain(
+ 'astryx-chat-unread-divider',
+ );
+ });
+});
diff --git a/packages/lab/src/Chat/ChatUnreadDivider.tsx b/packages/lab/src/Chat/ChatUnreadDivider.tsx
new file mode 100644
index 0000000000..cde9ee66a2
--- /dev/null
+++ b/packages/lab/src/Chat/ChatUnreadDivider.tsx
@@ -0,0 +1,113 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file ChatUnreadDivider.tsx
+ * @input Uses React, StyleX, theme tokens
+ * @output Exports ChatUnreadDivider component and ChatUnreadDividerProps
+ * @position Error-colored rule marking where unread messages begin
+ *
+ * Thin error-colored rule with a trailing label ("New" by default),
+ * rendered as an aria separator between read and unread messages in a
+ * chat thread.
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/lab/src/Chat/index.ts (exports)
+ * - /packages/lab/src/Chat/ChatUnreadDivider.doc.mjs
+ * - /apps/storybook/stories/ChatAdditions.stories.tsx (examples)
+ */
+
+import * as stylex from '@stylexjs/stylex';
+import {
+ colorVars,
+ spacingVars,
+ typographyVars,
+ typeScaleVars,
+ fontWeightVars,
+} from '@astryxdesign/core/theme/tokens.stylex';
+import type {BaseProps} from '@astryxdesign/core';
+import {mergeProps} from '@astryxdesign/core/utils';
+import {themeProps} from '@astryxdesign/core/utils';
+
+export interface ChatUnreadDividerProps extends BaseProps<HTMLDivElement> {
+ /** Ref forwarded to the root element */
+ ref?: React.Ref<HTMLDivElement>;
+
+ /**
+ * Divider label.
+ * @default 'New'
+ */
+ label?: string;
+}
+
+// =============================================================================
+// Styles
+// =============================================================================
+
+const styles = stylex.create({
+ root: {
+ display: 'flex',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-2'],
+ width: '100%',
+ paddingBlock: spacingVars['--spacing-1'],
+ },
+ line: {
+ flexGrow: 1,
+ height: 1,
+ backgroundColor: colorVars['--color-error'],
+ },
+ label: {
+ flexShrink: 0,
+ fontFamily: typographyVars['--font-family-body'],
+ fontSize: typeScaleVars['--text-supporting-size'],
+ fontWeight: fontWeightVars['--font-weight-bold'],
+ color: colorVars['--color-error'],
+ lineHeight: typeScaleVars['--text-supporting-leading'],
+ },
+});
+
+// =============================================================================
+// Component
+// =============================================================================
+
+/**
+ * Error-colored rule marking the first unread message in a chat thread.
+ *
+ * Renders as a separator with an accessible label describing where
+ * unread messages begin.
+ *
+ * @example
+ * ```
+ * <ChatUnreadDivider />
+ * <ChatUnreadDivider label="Unread" />
+ * ```
+ */
+export function ChatUnreadDivider({
+ label = 'New',
+ xstyle,
+ className,
+ style: styleProp,
+ 'data-testid': testId,
+ ref,
+}: ChatUnreadDividerProps) {
+ return (
+ <div
+ ref={ref}
+ role="separator"
+ aria-label={`${label} messages below`}
+ data-testid={testId}
+ {...mergeProps(
+ themeProps('chat-unread-divider'),
+ stylex.props(styles.root, xstyle),
+ className,
+ styleProp,
+ )}>
+ <span {...stylex.props(styles.line)} />
+ <span {...stylex.props(styles.label)}>{label}</span>
+ </div>
+ );
+}
+
+ChatUnreadDivider.displayName = 'ChatUnreadDivider';
diff --git a/packages/lab/src/Chat/index.ts b/packages/lab/src/Chat/index.ts
new file mode 100644
index 0000000000..2067317928
--- /dev/null
+++ b/packages/lab/src/Chat/index.ts
@@ -0,0 +1,22 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file Chat lab component barrel export
+ * @input Imports experimental chat affordances
+ * @output Exports lab chat components and related types
+ * @position Lab Chat entry point; re-exported by packages/lab/src/index.ts
+ */
+
+export {ChatReactionBar} from './ChatReactionBar';
+export type {ChatReactionBarProps, ChatReaction} from './ChatReactionBar';
+
+export {ChatEmojiPicker, DEFAULT_CHAT_EMOJIS} from './ChatEmojiPicker';
+export type {ChatEmojiPickerProps, ChatEmojiOption} from './ChatEmojiPicker';
+
+export {ChatUnreadDivider} from './ChatUnreadDivider';
+export type {ChatUnreadDividerProps} from './ChatUnreadDivider';
+
+export {ChatTypingIndicator} from './ChatTypingIndicator';
+export type {ChatTypingIndicatorProps} from './ChatTypingIndicator';
diff --git a/packages/lab/src/index.ts b/packages/lab/src/index.ts
index 00d305072a..84bb162bc2 100644
--- a/packages/lab/src/index.ts
+++ b/packages/lab/src/index.ts
@@ -30,6 +30,7 @@ export {
ChatReasoning,
type ChatReasoningProps,
} from './ChatReasoning/ChatReasoning';
+export * from './Chat';
// Drawer — experimental overlay panel
export {Drawer, type DrawerProps} from './Drawer';