# MessageScroller Keep a conversation readable as messages arrive, earlier history loads, or the reader jumps to a specific turn. [Interactive guide](/docs/components/messagescroller) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use MessageScroller to preserve reading position in a transcript with history, new turns or jump controls. ### How to compose it Start with the item-driven API and stable IDs. For custom markup, place the viewport, log content and registered item rows inside MessageScrollerProvider. ### What to verify Prepend a page while scrolled up, append a message while near the end and check that only the second case follows the newest turn automatically. ## Usage ```tsx import { MessageScroller } from 'wss3-forge' import type { MessageScrollerItem } from 'wss3-forge' ``` - MessageScrollerButton defaults to icon-sm. Choose size="sm" when supplying a text label. - For custom transcripts, place MessageScroller, Viewport, Content and registered Item rows inside MessageScrollerProvider. Give the frame a height. The viewport is a focusable region and the content is a log. - useMessageScroller returns scrollToMessage, scrollToStart and scrollToEnd. Subscribe to useMessageScrollerScrollable for edge state or useMessageScrollerVisibility for visible IDs and the current turn. - The pending-scroll state hides the viewport until a saved position is restored. Supply stable IDs and mounted target elements when using a virtualizer. Respect reduced-motion preferences when animating new rows. - Use stable IDs and keep message order chronological. Prepend earlier history to the same item list. - Set anchorId to navigate when the target changes. For a button that should work on every press, call scrollToMessage from a child of the provider. Use initialPosition="start" for a transcript that opens at the beginning. - New content follows the end while the reader is already near it. The user can jump to the latest content independently. ```tsx ({ id: message.id, content: message.text }))} /> ``` ## Runnable examples ### Streaming conversation ```tsx import { createContext, useContext, useEffect, useRef, useState } from 'react' import { Add16Regular, ArrowClockwise16Regular, Attach16Regular, Chat24Regular, Dismiss16Regular, Image16Regular, Search16Regular } from '@fluentui/react-icons' import * as DefaultParts from 'wss3-forge' import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentMedia, AttachmentTitle, Bubble, BubbleContent, Button, ChatComposer, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Message, MessageContent, MessageHeader, Text, useContextMenu, VStack } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } type ComposerMode = 'Create image' | 'Deep research' function LocalImage({ file, onRemove }: { file: File; onRemove?: () => void }) { const [url, setUrl] = useState('') useEffect(() => { const objectUrl = URL.createObjectURL(file) setUrl(objectUrl) return () => URL.revokeObjectURL(objectUrl) }, [file]) return {url && {file.name}} {file.name} {onRemove && } } function replyTo(message: string, mode: ComposerMode | null, file: File | null) { const topic = message || file?.name || 'your request' if (mode === 'Create image') return 'Simulated image brief for “' + topic + '”. Choose a focal point, a palette and the light direction before generating an image.' if (mode === 'Deep research') return 'Simulated research outline for “' + topic + '”. Start with the question, identify primary sources and compare the findings.' if (file) return 'Attached “' + file.name + '” to this conversation. The preview stays on your device.' if (/\b(latest|bottom|end)\b/i.test(message)) return 'Use Jump to latest to return to the newest message and follow the conversation again.' if (/\b(earlier|older|history)\b/i.test(message)) return 'Load older messages at the top. Keeping the same message IDs lets the transcript stay on the line you were reading.' if (/\b(stream\w*|follow\w*|scroll\w*)\b/i.test(message)) return 'Stay near the latest message to follow new text as it arrives. Scroll up to read an earlier exchange at your own pace.' return 'Try asking about scrolling, earlier messages or jumping to the latest reply. Those are the topics this local demo can answer.' } function ChatPreview() { const { MessageScroller } = useContext(ScrollerLibrary) const [draft, setDraft] = useState('') const [turns, setTurns] = useState<{ prompt: string; reply: string; image: File | null }[]>([]) const [image, setImage] = useState(null) const [imageError, setImageError] = useState('') const [mode, setMode] = useState(null) const picker = useRef(null) const { getTriggerProps, ContextMenuComponent } = useContextMenu() const [shown, setShown] = useState(0) const last = turns[turns.length - 1] const words = last ? last.reply.split(' ').length : 0 const streaming = shown < words useEffect(() => { if (!streaming) return const timer = window.setInterval(() => setShown(count => Math.min(count + 1, words)), 60) return () => window.clearInterval(timer) }, [streaming, words]) function send(prompt: string) { if (streaming || (!prompt.trim() && !image)) return setTurns(current => [...current, { prompt, reply: replyTo(prompt, mode, image), image }]) setImage(null) setImageError('') setShown(1) } const items = turns.flatMap(({ prompt, reply, image: sentImage }, index) => [ { id: 'question-' + index, content: You {prompt && {prompt}} {sentImage && } }, { id: 'answer-' + index, content: }, ]) return New chatSimulated replies
{!last && Start a conversation Ask about scrolling or loading earlier messages. }
{ const file = event.currentTarget.files?.[0] event.currentTarget.value = '' if (!file) return const unknownType = !file.type || file.type === 'application/octet-stream' const imageExtension = /\.(avif|bmp|gif|ico|jpe?g|jfif|png|svg|tiff?|webp)$/i.test(file.name) if (!file.type.startsWith('image/') && !(unknownType && imageExtension)) { setImageError('Choose an image file.') return } setImage(file) setImageError('') }} /> {image && setImage(null)} />} {imageError && {imageError}} {mode && } } /> {ContextMenuComponent}
} export default function Example() { return () } ``` ### Anchoring turns ```tsx import { createContext, useContext, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` ### Group chat ```tsx import { createContext, useContext, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` ### Keeping context visible ```tsx import { createContext, useContext, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` ### Following the live edge ```tsx import { createContext, useContext, useEffect, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function StreamingExample() { const [chunks, setChunks] = useState(0) const pieces = ['The release', ' has passed', ' every check', ' and is ready', ' to publish.'] const total = pieces.length useEffect(() => { if (!chunks || chunks >= total) return const timer = window.setTimeout(() => setChunks(chunks + 1), 300) return () => window.clearTimeout(timer) }, [chunks, total]) const rows = chunks ? [...savedThread, { id: 'response', sender: 'Kai', text: pieces.slice(0, chunks).join('') }] : savedThread return } export default function Example() { return () } ``` ### Opening saved threads ```tsx import { createContext, useContext, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function SavedExample() { const [position, setPosition] = useState('end') const [opened, setOpened] = useState(0) return {(['start', 'end', 'last-anchor'] as const).map(value => )} } export default function Example() { return () } ``` ### Loading earlier messages ```tsx import { createContext, useContext, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function EarlierExample() { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 return } export default function Example() { return () } ``` ### Animating new messages ```tsx import { createContext, useContext, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` ### Jumping to messages ```tsx import { createContext, useContext, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function ScrollCommands() { const { useMessageScroller } = useContext(ScrollerLibrary) const { scrollToMessage, scrollToStart, scrollToEnd } = useMessageScroller() return } function CommandsExample() { return } export default function Example() { return () } ``` ### Tracking the reader’s position ```tsx import { createContext, useContext, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function VisibleRows() { const { useMessageScrollerVisibility } = useContext(ScrollerLibrary) const visible = useMessageScrollerVisibility() return Current turn {visible.currentAnchorId ?? 'none'} · Visible {visible.visibleMessageIds.join(', ') || 'none'} } function VisibilityExample() { return } export default function Example() { return () } ``` ### Reading scroll state ```tsx import { createContext, useContext, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function EdgeState() { const { useMessageScrollerScrollable } = useContext(ScrollerLibrary) const edges = useMessageScrollerScrollable() return Earlier messages {edges.start ? 'above' : 'at start'} · Later messages {edges.end ? 'below' : 'at end'} } function StateExample() { return } export default function Example() { return () } ``` ### Append, prepend and jump in a transcript ```tsx import { createContext, useContext, useState, type ReactNode } from 'react' import * as DefaultParts from 'wss3-forge' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type ScrollerParts = Pick const ScrollerLibrary = createContext(DefaultParts) type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton } = useContext(ScrollerLibrary) const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { const { MessageScrollerProvider } = useContext(ScrollerLibrary) return {children} } function ApprovalButton() { const { useMessageScroller } = useContext(ScrollerLibrary) const { scrollToMessage } = useMessageScroller() return } function ScrollerExample() { const [rows, setRows] = useState(savedThread) const earlier = rows.some(row => row.id === 'earlier') const appended = rows.some(row => row.id === 'final') return } export default function Example() { return () } ``` ## Primitive libraries ### Base UI This entry re-exports the Forge transcript controller, viewport, item parts and scroll hooks. ```sh npm install wss3-forge @base-ui/react ``` ```tsx import { MessageScroller } from 'wss3-forge/base-ui' import { useEffect, useRef, useState } from 'react' import { Add16Regular, ArrowClockwise16Regular, Attach16Regular, Chat24Regular, Dismiss16Regular, Image16Regular, Search16Regular } from '@fluentui/react-icons' import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentMedia, AttachmentTitle, Bubble, BubbleContent, Button, ChatComposer, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Message, MessageContent, MessageHeader, Text, useContextMenu, VStack } from 'wss3-forge' function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } type ComposerMode = 'Create image' | 'Deep research' function LocalImage({ file, onRemove }: { file: File; onRemove?: () => void }) { const [url, setUrl] = useState('') useEffect(() => { const objectUrl = URL.createObjectURL(file) setUrl(objectUrl) return () => URL.revokeObjectURL(objectUrl) }, [file]) return {url && {file.name}} {file.name} {onRemove && } } function replyTo(message: string, mode: ComposerMode | null, file: File | null) { const topic = message || file?.name || 'your request' if (mode === 'Create image') return 'Simulated image brief for “' + topic + '”. Choose a focal point, a palette and the light direction before generating an image.' if (mode === 'Deep research') return 'Simulated research outline for “' + topic + '”. Start with the question, identify primary sources and compare the findings.' if (file) return 'Attached “' + file.name + '” to this conversation. The preview stays on your device.' if (/\b(latest|bottom|end)\b/i.test(message)) return 'Use Jump to latest to return to the newest message and follow the conversation again.' if (/\b(earlier|older|history)\b/i.test(message)) return 'Load older messages at the top. Keeping the same message IDs lets the transcript stay on the line you were reading.' if (/\b(stream\w*|follow\w*|scroll\w*)\b/i.test(message)) return 'Stay near the latest message to follow new text as it arrives. Scroll up to read an earlier exchange at your own pace.' return 'Try asking about scrolling, earlier messages or jumping to the latest reply. Those are the topics this local demo can answer.' } function ChatPreview() { const [draft, setDraft] = useState('') const [turns, setTurns] = useState<{ prompt: string; reply: string; image: File | null }[]>([]) const [image, setImage] = useState(null) const [imageError, setImageError] = useState('') const [mode, setMode] = useState(null) const picker = useRef(null) const { getTriggerProps, ContextMenuComponent } = useContextMenu() const [shown, setShown] = useState(0) const last = turns[turns.length - 1] const words = last ? last.reply.split(' ').length : 0 const streaming = shown < words useEffect(() => { if (!streaming) return const timer = window.setInterval(() => setShown(count => Math.min(count + 1, words)), 60) return () => window.clearInterval(timer) }, [streaming, words]) function send(prompt: string) { if (streaming || (!prompt.trim() && !image)) return setTurns(current => [...current, { prompt, reply: replyTo(prompt, mode, image), image }]) setImage(null) setImageError('') setShown(1) } const items = turns.flatMap(({ prompt, reply, image: sentImage }, index) => [ { id: 'question-' + index, content: You {prompt && {prompt}} {sentImage && } }, { id: 'answer-' + index, content: }, ]) return New chatSimulated replies
{!last && Start a conversation Ask about scrolling or loading earlier messages. }
{ const file = event.currentTarget.files?.[0] event.currentTarget.value = '' if (!file) return const unknownType = !file.type || file.type === 'application/octet-stream' const imageExtension = /\.(avif|bmp|gif|ico|jpe?g|jfif|png|svg|tiff?|webp)$/i.test(file.name) if (!file.type.startsWith('image/') && !(unknownType && imageExtension)) { setImageError('Choose an image file.') return } setImage(file) setImageError('') }} /> {image && setImage(null)} />} {imageError && {imageError}} {mode && } } /> {ContextMenuComponent}
} export default function Example() { return () } ``` #### Anchoring turns ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/base-ui' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` #### Group chat ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/base-ui' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` #### Keeping context visible ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/base-ui' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` #### Following the live edge ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/base-ui' import { useEffect, useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function StreamingExample() { const [chunks, setChunks] = useState(0) const pieces = ['The release', ' has passed', ' every check', ' and is ready', ' to publish.'] const total = pieces.length useEffect(() => { if (!chunks || chunks >= total) return const timer = window.setTimeout(() => setChunks(chunks + 1), 300) return () => window.clearTimeout(timer) }, [chunks, total]) const rows = chunks ? [...savedThread, { id: 'response', sender: 'Kai', text: pieces.slice(0, chunks).join('') }] : savedThread return } export default function Example() { return () } ``` #### Opening saved threads ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/base-ui' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function SavedExample() { const [position, setPosition] = useState('end') const [opened, setOpened] = useState(0) return {(['start', 'end', 'last-anchor'] as const).map(value => )} } export default function Example() { return () } ``` #### Loading earlier messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/base-ui' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function EarlierExample() { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 return } export default function Example() { return () } ``` #### Animating new messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/base-ui' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` #### Jumping to messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScroller } from 'wss3-forge/base-ui' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function ScrollCommands() { const { scrollToMessage, scrollToStart, scrollToEnd } = useMessageScroller() return } function CommandsExample() { return } export default function Example() { return () } ``` #### Tracking the reader’s position ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScrollerVisibility } from 'wss3-forge/base-ui' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function VisibleRows() { const visible = useMessageScrollerVisibility() return Current turn {visible.currentAnchorId ?? 'none'} · Visible {visible.visibleMessageIds.join(', ') || 'none'} } function VisibilityExample() { return } export default function Example() { return () } ``` #### Reading scroll state ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScrollerScrollable } from 'wss3-forge/base-ui' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function EdgeState() { const edges = useMessageScrollerScrollable() return Earlier messages {edges.start ? 'above' : 'at start'} · Later messages {edges.end ? 'below' : 'at end'} } function StateExample() { return } export default function Example() { return () } ``` #### Append, prepend and jump in a transcript ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScroller } from 'wss3-forge/base-ui' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function ApprovalButton() { const { scrollToMessage } = useMessageScroller() return } function ScrollerExample() { const [rows, setRows] = useState(savedThread) const earlier = rows.some(row => row.id === 'earlier') const appended = rows.some(row => row.id === 'final') return } export default function Example() { return () } ``` ### Radix This entry re-exports the Forge transcript controller, viewport, item parts and scroll hooks. ```sh npm install wss3-forge radix-ui ``` ```tsx import { MessageScroller } from 'wss3-forge/radix' import { useEffect, useRef, useState } from 'react' import { Add16Regular, ArrowClockwise16Regular, Attach16Regular, Chat24Regular, Dismiss16Regular, Image16Regular, Search16Regular } from '@fluentui/react-icons' import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentMedia, AttachmentTitle, Bubble, BubbleContent, Button, ChatComposer, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Message, MessageContent, MessageHeader, Text, useContextMenu, VStack } from 'wss3-forge' function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } type ComposerMode = 'Create image' | 'Deep research' function LocalImage({ file, onRemove }: { file: File; onRemove?: () => void }) { const [url, setUrl] = useState('') useEffect(() => { const objectUrl = URL.createObjectURL(file) setUrl(objectUrl) return () => URL.revokeObjectURL(objectUrl) }, [file]) return {url && {file.name}} {file.name} {onRemove && } } function replyTo(message: string, mode: ComposerMode | null, file: File | null) { const topic = message || file?.name || 'your request' if (mode === 'Create image') return 'Simulated image brief for “' + topic + '”. Choose a focal point, a palette and the light direction before generating an image.' if (mode === 'Deep research') return 'Simulated research outline for “' + topic + '”. Start with the question, identify primary sources and compare the findings.' if (file) return 'Attached “' + file.name + '” to this conversation. The preview stays on your device.' if (/\b(latest|bottom|end)\b/i.test(message)) return 'Use Jump to latest to return to the newest message and follow the conversation again.' if (/\b(earlier|older|history)\b/i.test(message)) return 'Load older messages at the top. Keeping the same message IDs lets the transcript stay on the line you were reading.' if (/\b(stream\w*|follow\w*|scroll\w*)\b/i.test(message)) return 'Stay near the latest message to follow new text as it arrives. Scroll up to read an earlier exchange at your own pace.' return 'Try asking about scrolling, earlier messages or jumping to the latest reply. Those are the topics this local demo can answer.' } function ChatPreview() { const [draft, setDraft] = useState('') const [turns, setTurns] = useState<{ prompt: string; reply: string; image: File | null }[]>([]) const [image, setImage] = useState(null) const [imageError, setImageError] = useState('') const [mode, setMode] = useState(null) const picker = useRef(null) const { getTriggerProps, ContextMenuComponent } = useContextMenu() const [shown, setShown] = useState(0) const last = turns[turns.length - 1] const words = last ? last.reply.split(' ').length : 0 const streaming = shown < words useEffect(() => { if (!streaming) return const timer = window.setInterval(() => setShown(count => Math.min(count + 1, words)), 60) return () => window.clearInterval(timer) }, [streaming, words]) function send(prompt: string) { if (streaming || (!prompt.trim() && !image)) return setTurns(current => [...current, { prompt, reply: replyTo(prompt, mode, image), image }]) setImage(null) setImageError('') setShown(1) } const items = turns.flatMap(({ prompt, reply, image: sentImage }, index) => [ { id: 'question-' + index, content: You {prompt && {prompt}} {sentImage && } }, { id: 'answer-' + index, content: }, ]) return New chatSimulated replies
{!last && Start a conversation Ask about scrolling or loading earlier messages. }
{ const file = event.currentTarget.files?.[0] event.currentTarget.value = '' if (!file) return const unknownType = !file.type || file.type === 'application/octet-stream' const imageExtension = /\.(avif|bmp|gif|ico|jpe?g|jfif|png|svg|tiff?|webp)$/i.test(file.name) if (!file.type.startsWith('image/') && !(unknownType && imageExtension)) { setImageError('Choose an image file.') return } setImage(file) setImageError('') }} /> {image && setImage(null)} />} {imageError && {imageError}} {mode && } } /> {ContextMenuComponent}
} export default function Example() { return () } ``` #### Anchoring turns ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/radix' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` #### Group chat ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/radix' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` #### Keeping context visible ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/radix' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` #### Following the live edge ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/radix' import { useEffect, useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function StreamingExample() { const [chunks, setChunks] = useState(0) const pieces = ['The release', ' has passed', ' every check', ' and is ready', ' to publish.'] const total = pieces.length useEffect(() => { if (!chunks || chunks >= total) return const timer = window.setTimeout(() => setChunks(chunks + 1), 300) return () => window.clearTimeout(timer) }, [chunks, total]) const rows = chunks ? [...savedThread, { id: 'response', sender: 'Kai', text: pieces.slice(0, chunks).join('') }] : savedThread return } export default function Example() { return () } ``` #### Opening saved threads ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/radix' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function SavedExample() { const [position, setPosition] = useState('end') const [opened, setOpened] = useState(0) return {(['start', 'end', 'last-anchor'] as const).map(value => )} } export default function Example() { return () } ``` #### Loading earlier messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/radix' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function EarlierExample() { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 return } export default function Example() { return () } ``` #### Animating new messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/radix' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` #### Jumping to messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScroller } from 'wss3-forge/radix' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function ScrollCommands() { const { scrollToMessage, scrollToStart, scrollToEnd } = useMessageScroller() return } function CommandsExample() { return } export default function Example() { return () } ``` #### Tracking the reader’s position ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScrollerVisibility } from 'wss3-forge/radix' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function VisibleRows() { const visible = useMessageScrollerVisibility() return Current turn {visible.currentAnchorId ?? 'none'} · Visible {visible.visibleMessageIds.join(', ') || 'none'} } function VisibilityExample() { return } export default function Example() { return () } ``` #### Reading scroll state ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScrollerScrollable } from 'wss3-forge/radix' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function EdgeState() { const edges = useMessageScrollerScrollable() return Earlier messages {edges.start ? 'above' : 'at start'} · Later messages {edges.end ? 'below' : 'at end'} } function StateExample() { return } export default function Example() { return () } ``` #### Append, prepend and jump in a transcript ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScroller } from 'wss3-forge/radix' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function ApprovalButton() { const { scrollToMessage } = useMessageScroller() return } function ScrollerExample() { const [rows, setRows] = useState(savedThread) const earlier = rows.some(row => row.id === 'earlier') const appended = rows.some(row => row.id === 'final') return } export default function Example() { return () } ``` ### React Aria This entry re-exports the Forge transcript controller, viewport, item parts and scroll hooks. ```sh npm install wss3-forge react-aria-components ``` ```tsx import { MessageScroller } from 'wss3-forge/react-aria' import { useEffect, useRef, useState } from 'react' import { Add16Regular, ArrowClockwise16Regular, Attach16Regular, Chat24Regular, Dismiss16Regular, Image16Regular, Search16Regular } from '@fluentui/react-icons' import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentMedia, AttachmentTitle, Bubble, BubbleContent, Button, ChatComposer, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Message, MessageContent, MessageHeader, Text, useContextMenu, VStack } from 'wss3-forge' function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } type ComposerMode = 'Create image' | 'Deep research' function LocalImage({ file, onRemove }: { file: File; onRemove?: () => void }) { const [url, setUrl] = useState('') useEffect(() => { const objectUrl = URL.createObjectURL(file) setUrl(objectUrl) return () => URL.revokeObjectURL(objectUrl) }, [file]) return {url && {file.name}} {file.name} {onRemove && } } function replyTo(message: string, mode: ComposerMode | null, file: File | null) { const topic = message || file?.name || 'your request' if (mode === 'Create image') return 'Simulated image brief for “' + topic + '”. Choose a focal point, a palette and the light direction before generating an image.' if (mode === 'Deep research') return 'Simulated research outline for “' + topic + '”. Start with the question, identify primary sources and compare the findings.' if (file) return 'Attached “' + file.name + '” to this conversation. The preview stays on your device.' if (/\b(latest|bottom|end)\b/i.test(message)) return 'Use Jump to latest to return to the newest message and follow the conversation again.' if (/\b(earlier|older|history)\b/i.test(message)) return 'Load older messages at the top. Keeping the same message IDs lets the transcript stay on the line you were reading.' if (/\b(stream\w*|follow\w*|scroll\w*)\b/i.test(message)) return 'Stay near the latest message to follow new text as it arrives. Scroll up to read an earlier exchange at your own pace.' return 'Try asking about scrolling, earlier messages or jumping to the latest reply. Those are the topics this local demo can answer.' } function ChatPreview() { const [draft, setDraft] = useState('') const [turns, setTurns] = useState<{ prompt: string; reply: string; image: File | null }[]>([]) const [image, setImage] = useState(null) const [imageError, setImageError] = useState('') const [mode, setMode] = useState(null) const picker = useRef(null) const { getTriggerProps, ContextMenuComponent } = useContextMenu() const [shown, setShown] = useState(0) const last = turns[turns.length - 1] const words = last ? last.reply.split(' ').length : 0 const streaming = shown < words useEffect(() => { if (!streaming) return const timer = window.setInterval(() => setShown(count => Math.min(count + 1, words)), 60) return () => window.clearInterval(timer) }, [streaming, words]) function send(prompt: string) { if (streaming || (!prompt.trim() && !image)) return setTurns(current => [...current, { prompt, reply: replyTo(prompt, mode, image), image }]) setImage(null) setImageError('') setShown(1) } const items = turns.flatMap(({ prompt, reply, image: sentImage }, index) => [ { id: 'question-' + index, content: You {prompt && {prompt}} {sentImage && } }, { id: 'answer-' + index, content: }, ]) return New chatSimulated replies
{!last && Start a conversation Ask about scrolling or loading earlier messages. }
{ const file = event.currentTarget.files?.[0] event.currentTarget.value = '' if (!file) return const unknownType = !file.type || file.type === 'application/octet-stream' const imageExtension = /\.(avif|bmp|gif|ico|jpe?g|jfif|png|svg|tiff?|webp)$/i.test(file.name) if (!file.type.startsWith('image/') && !(unknownType && imageExtension)) { setImageError('Choose an image file.') return } setImage(file) setImageError('') }} /> {image && setImage(null)} />} {imageError && {imageError}} {mode && } } /> {ContextMenuComponent}
} export default function Example() { return () } ``` #### Anchoring turns ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/react-aria' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` #### Group chat ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/react-aria' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` #### Keeping context visible ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/react-aria' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, Pills, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function Turns({ chooseAnchor = false, peek = 0 }: { chooseAnchor?: boolean; peek?: number }) { const [rows, setRows] = useState(savedThread) const [anchor, setAnchor] = useState('question') const [context, setContext] = useState(peek) return {peek > 0 && setContext(Number(value))} options={[{ id: '0', label: 'No peek' }, { id: '32', label: '32 px' }, { id: '64', label: '64 px' }]} />} {chooseAnchor && } } export default function Example() { return () } ``` #### Following the live edge ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/react-aria' import { useEffect, useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function StreamingExample() { const [chunks, setChunks] = useState(0) const pieces = ['The release', ' has passed', ' every check', ' and is ready', ' to publish.'] const total = pieces.length useEffect(() => { if (!chunks || chunks >= total) return const timer = window.setTimeout(() => setChunks(chunks + 1), 300) return () => window.clearTimeout(timer) }, [chunks, total]) const rows = chunks ? [...savedThread, { id: 'response', sender: 'Kai', text: pieces.slice(0, chunks).join('') }] : savedThread return } export default function Example() { return () } ``` #### Opening saved threads ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/react-aria' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function SavedExample() { const [position, setPosition] = useState('end') const [opened, setOpened] = useState(0) return {(['start', 'end', 'last-anchor'] as const).map(value => )} } export default function Example() { return () } ``` #### Loading earlier messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/react-aria' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function EarlierExample() { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 return } export default function Example() { return () } ``` #### Animating new messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider } from 'wss3-forge/react-aria' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function AppendExample({ group = false }: { group?: boolean }) { const [rows, setRows] = useState(savedThread) const number = rows.length - savedThread.length + 1 const sender = ['Amina', 'Kai', 'Lee'][(number - 1) % 3] return } export default function Example() { return () } ``` #### Jumping to messages ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScroller } from 'wss3-forge/react-aria' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function ScrollCommands() { const { scrollToMessage, scrollToStart, scrollToEnd } = useMessageScroller() return } function CommandsExample() { return } export default function Example() { return () } ``` #### Tracking the reader’s position ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScrollerVisibility } from 'wss3-forge/react-aria' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function VisibleRows() { const visible = useMessageScrollerVisibility() return Current turn {visible.currentAnchorId ?? 'none'} · Visible {visible.visibleMessageIds.join(', ') || 'none'} } function VisibilityExample() { return } export default function Example() { return () } ``` #### Reading scroll state ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScrollerScrollable } from 'wss3-forge/react-aria' import { type ReactNode } from 'react' import { Bubble, BubbleContent, Message, MessageContent, MessageHeader, Text, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function EdgeState() { const edges = useMessageScrollerScrollable() return Earlier messages {edges.start ? 'above' : 'at start'} · Later messages {edges.end ? 'below' : 'at end'} } function StateExample() { return } export default function Example() { return () } ``` #### Append, prepend and jump in a transcript ```tsx import { MessageScroller, MessageScrollerViewport, MessageScrollerContent, MessageScrollerItem, MessageScrollerButton, MessageScrollerProvider, useMessageScroller } from 'wss3-forge/react-aria' import { useState, type ReactNode } from 'react' import { Bubble, BubbleContent, Button, HStack, Message, MessageContent, MessageHeader, useReducedMotion, VStack } from 'wss3-forge' import type { MessageScrollerDefaultScrollPosition } from 'wss3-forge' type Entry = { id: string; sender: string; text: string; anchor?: boolean } const savedThread: Entry[] = [ { id: 'question', sender: 'Amina', text: 'Which build are we reviewing?', anchor: true }, { id: 'build', sender: 'Kai', text: 'The release candidate includes the updated navigation.' }, { id: 'checks', sender: 'Lee', text: 'All keyboard checks passed on the latest build.' }, { id: 'approval', sender: 'Amina', text: 'Can we approve the release?', anchor: true }, { id: 'review', sender: 'Kai', text: 'I am reading the accessibility report now.' }, { id: 'mobile', sender: 'Lee', text: 'Mobile layout and screen reader checks are complete.' }, ] function ChatLine({ sender, text, outgoing = false }: { sender: string; text: string; outgoing?: boolean }) { return {sender} {text} } function ThreadFrame({ rows, label, animate = false, anchors = true, latestLabel }: { rows: Entry[]; label: string; animate?: boolean; anchors?: boolean; latestLabel?: string }) { const reduced = useReducedMotion() return {rows.map(row => { if (node && animate && !reduced && row.id.startsWith('update-') && !node.dataset.played) { node.dataset.played = 'true' node.animate([{ opacity: 0 }, { opacity: 1 }], { duration: 250 }) } }}>)} } function Sample({ children, position = 'end', follow = false, peek = 0 }: { children: ReactNode; position?: MessageScrollerDefaultScrollPosition; follow?: boolean; peek?: number }) { return {children} } function ApprovalButton() { const { scrollToMessage } = useMessageScroller() return } function ScrollerExample() { const [rows, setRows] = useState(savedThread) const earlier = rows.some(row => row.id === 'earlier') const appended = rows.some(row => row.id === 'final') return } export default function Example() { return () } ``` ## Root package API ### MessageScroller Keep a conversation readable as messages arrive, earlier history loads, or the reader jumps to a specific turn. Props type: `MessageScrollerProps | MessageScrollerRootProps` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes **Composition exports** - `MessageScrollerViewport` (named export) - `MessageScrollerContent` (named export) - `MessageScrollerItem` (named export) - `MessageScrollerButton` (named export) - `MessageScrollerProvider` (named export) - `items?` — `readonly MessageScrollerItem[]` Compact form. Set height, gap, label, follow, initialPosition, anchorId and showJumpButton on the same component. - `label?` — `string` Accessible name of the compact viewport. - `height?` — `number | string` Height of the scrolling region in the compact items API. - `gap?` — `number | string` Spacing between compact transcript rows. - `initialPosition?` — `'start' | 'end'` Options `"start"`, `"end"`. Choose where the compact transcript opens. - `anchorId?` — `string` Navigate to a new target ID when that row is available. - `follow?` — `boolean` Follow arriving content while the reader remains at the end. - `showJumpButton?` — `boolean` Show the compact jump-to-latest command while newer content is out of view. - `ref?` — `React.LegacyRef | undefined` #### MessageScrollerRootProps Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes #### MessageScrollerProps - `items` — `readonly MessageScrollerItem[]` Compact form. Set height, gap, label, follow, initialPosition, anchorId and showJumpButton on the same component. - `label?` — `string` Accessible name of the compact viewport. - `height?` — `number | string` Height of the scrolling region in the compact items API. - `gap?` — `number | string` Spacing between compact transcript rows. - `initialPosition?` — `'start' | 'end'` Options `"start"`, `"end"`. Choose where the compact transcript opens. - `anchorId?` — `string` Navigate to a new target ID when that row is available. - `follow?` — `boolean` Follow arriving content while the reader remains at the end. - `showJumpButton?` — `boolean` Show the compact jump-to-latest command while newer content is out of view. ### MessageScrollerViewport Props type: `MessageScrollerViewportProps` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes, RefAttributes - `ref?` — `React.LegacyRef | undefined` Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). - `preserveScrollOnPrepend?` — `boolean` Default `true`. ### MessageScrollerContent Props type: `MessageScrollerContentProps` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes, RefAttributes - `ref?` — `React.LegacyRef | undefined` Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). - `spacerClassName?` — `string` ### MessageScrollerItem Props type: `MessageScrollerItemProps` Native attributes: AriaAttributes, Attributes, DOMAttributes, HTMLAttributes, RefAttributes - `ref?` — `React.LegacyRef | undefined` Allows getting a ref to the component instance. Once the component unmounts, React will set `ref.current` to `null` (or call the ref with `null` if you passed a callback ref). - `messageId?` — `string` - `scrollAnchor?` — `boolean` Default `false`. ### MessageScrollerButton Props type: `MessageScrollerButtonProps` Native attributes: AriaAttributes, Attributes, ButtonHTMLAttributes, DOMAttributes, HTMLAttributes - `ref?` — `((instance: HTMLButtonElement | null) => void | React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof React.DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | React.RefObject | null | undefined` - `render?` — `Renderer` - `variant?` — `ButtonVariant | null` Default `'secondary'`. Options `null`, `"default"`, `"primary"`, `"secondary"`, `"danger"`, `"destructive"`, `"ghost"`, `"outline"`, `"link"`. - `size?` — `ButtonSize | null` Default `'icon-sm'`. Options `null`, `"default"`, `"icon"`, `"sm"`, `"md"`, `"lg"`, `"xs"`, `"xl"`, `"icon-xs"`, `"icon-sm"`, `"icon-lg"`, `"icon-xl"`. - `behavior?` — `ScrollBehavior` Default `'smooth'`. Options `"auto"`, `"smooth"`, `"instant"`. - `direction?` — `MessageScrollerButtonDirection` Default `'end'`. Options `"start"`, `"end"`. ### MessageScrollerProvider Props type: `MessageScrollerProviderProps` - `children?` — `ReactNode` - `autoScroll?` — `boolean` Default `false`. - `defaultScrollPosition?` — `MessageScrollerDefaultScrollPosition` Default `'end'`. Options `"start"`, `"end"`, `"last-anchor"`. - `scrollEdgeThreshold?` — `number` Default `8`. - `scrollPreviousItemPeek?` — `number` Default `64`. - `scrollMargin?` — `number` Default `0`. ## Related types ```ts export interface MessageScrollerProps { items: readonly MessageScrollerItem[] label?: string height?: number | string gap?: number | string initialPosition?: 'start' | 'end' anchorId?: string follow?: boolean showJumpButton?: boolean } type MessageScrollerRootProps = ComponentPropsWithoutRef<'div'> export type MessageScrollerViewportProps = React.ComponentProps<'div'> & {preserveScrollOnPrepend?: boolean} export type MessageScrollerContentProps = React.ComponentProps<'div'> & {spacerClassName?: string} export type MessageScrollerItemProps = React.ComponentProps<'div'> & {messageId?: string; scrollAnchor?: boolean} type Renderer = ReactElement | ((attributes: Attributes, state: State) => ReactElement | null) type Attributes = Record export type ButtonVariant = 'default' | 'destructive' | 'primary' | 'secondary' | 'ghost' | 'danger' | 'outline' | 'link' export type ButtonSize = ControlSize | 'default' | 'icon' | 'icon-xs' | 'icon-sm' | 'icon-lg' | 'icon-xl' export type ControlSize = keyof typeof SIZES export type MessageScrollerButtonDirection = 'start' | 'end' export type MessageScrollerButtonProps = ForgePartProps<'button', MessageScrollerButtonRenderState> & Pick, 'variant' | 'size'> & {behavior?: ScrollBehavior; direction?: MessageScrollerButtonDirection} export type ForgePartProps> = ComponentPropsWithRef & { render?: Renderer } type Tag = keyof React.JSX.IntrinsicElements export type MessageScrollerButtonRenderState = { active: boolean; direction: MessageScrollerButtonDirection } export type MessageScrollerDefaultScrollPosition = 'start' | 'end' | 'last-anchor' export interface MessageScrollerProviderProps { children?: ReactNode autoScroll?: boolean defaultScrollPosition?: MessageScrollerDefaultScrollPosition scrollEdgeThreshold?: number scrollPreviousItemPeek?: number scrollMargin?: number } ``` ## Optional primitive contracts - [wss3-forge/base-ui · MessageScroller contract](/ai/skill/primitive-api/MessageScroller.json) - [wss3-forge/radix · MessageScroller contract](/ai/skill/primitive-api/MessageScroller.json) - [wss3-forge/react-aria · MessageScroller contract](/ai/skill/primitive-api/MessageScroller.json)