The message type, which must extend IdentifiableMessage.
OptionalalignmentAlignment of the chat list. Determines whether new messages appear at the top or bottom.
OptionalbufferExtra item space in pixels to render beyond the visible area (for virtualization performance).
Passed to Virtua's bufferSize prop.
OptionalclassClass name for the root element of the chat viewer.
OptionalgetReturns a stable key for a message. Use it when the id of a message can change,
for example when an optimistic message gets its id from the server.
A message that keeps its key keeps its rendered element and its state,
and it is not reported as a new message to ChatViewerProps.onNewerMessages
or ChatViewerProps.onOlderMessages.
OptionalhistoryOffset in pixels from the end of the history at which to trigger onHistoryEndReached.
OptionalkeepMessageIds of messages to keep mounted even when out of view.
OptionalkeepIndexes of messages to keep mounted even when out of view. This allows you to preserve the state of messages that are not currently visible.
The array of messages to display in the chat viewer.
OptionalonCallback fired when the viewport reaches the bottom of the message list.
ChatViewerHandle instance. Allows you to control the chat viewer.
OptionalonCallback fired when the viewport reaches the top of the message list.
ChatViewerHandle instance. Allows you to control the chat viewer.
OptionalonCallback fired when the size of the rendered content changes, for example when a streamed message grows or an image loads. ChatViewerHandle.atBottom still has the value from before the change, so followAtBottom keeps the chat at the bottom while the content grows.
<ChatViewer
messages={messages}
renderMessage={renderMessage}
onContentResize={followAtBottom()}
/>
ChatViewerHandle instance. Allows you to control the chat viewer.
OptionalonCallback fired when the user scrolls to the end of the history (top or bottom, depending on alignment).
ChatViewerHandle instance. Allows you to control the chat viewer.
OptionalonCallback fired on key down events in the scrollable container.
OptionalonCallback fired when newer messages are requested (e.g., user scrolls to the bottom).
You might want to use this callback with utility functions like followEveryMessage, followMessagesAtBottom, or followMessagesBy to automatically scroll to automatically follow new messages.
<ChatViewer
messages={messages}
renderMessage={renderMessage}
onNewerMessages={followMessagesAtBottom()}
/>
ChatViewerHandle instance. Allows you to control the chat viewer.
followMessagesAtBottom - scrolls to the bottom when viewport is at the bottom of the history.
OptionalonCallback fired when older messages are requested (e.g., user scrolls to the top).
ChatViewerHandle instance. Allows you to control the chat viewer.
OptionalonCallback fired when the prefix node is displayed in the viewport.
ChatViewerHandle instance. Allows you to control the chat viewer.
OptionalonCallback fired on scroll with the current scroll offset.
The current scroll offset.
OptionalonCallback fired when scrolling ends.
OptionalonCallback fired when the suffix node is displayed in the viewport.
ChatViewerHandle instance. Allows you to control the chat viewer.
followSuffixAtBottom - scrolls to the bottom when viewport when suffix is displayed at the bottom of the history.
OptionalonCallback fired when the pin lets go of the list: the user scrolled away, or ChatViewerHandle.unpin was called.
ChatViewerHandle instance. Allows you to control the chat viewer.
OptionalonCallback fired on wheel events in the scrollable container.
OptionaloverscanExtra item space in pixels to render beyond the visible area (for virtualization performance).
Passed to Virtua's bufferSize prop when bufferSize is not set.
Use bufferSize instead.
Optionalpinnedid of a message to keep at the top of the viewport, with room under it.
The content that comes after the message fills the room, so a streamed answer does not move the list.
The pin holds until the user scrolls away, ChatViewerHandle.unpin is called, or this prop changes.
While the pin holds, the follow strategies do not scroll the chat.
To pin new messages by a condition, use pinMessagesBy instead.
OptionalpinOptionalprefixReact node to render before the message list (e.g., a header or history loader). It can be conditionally displayed. When changed, it will trigger a onPrefixDisplay callback.
Function to render a message.
OptionalscrollerClass name for the scrollable container.
OptionalscrollerRef to the scrollable container element. Use it to measure the scroller or to listen to its DOM events.
OptionalscrollerStyle for the scrollable container.
OptionalssrNumber of items to render on the server for SSR. Passed to Virtua's ssrCount prop.
OptionalstyleStyle for the root element of the chat viewer.
OptionalsuffixReact node to render after the message list (e.g., a footer or typing indicator). It can be conditionally displayed. When changed, it will trigger a onSuffixDisplay callback.
Props for the ChatViewer component.