Chat

Description

A component to display a chat

ChatArea is a scrolling transcript built for streaming replies. It follows the live edge while the reader is at the bottom, stops following the moment they scroll up so new content doesn't pull them back, and shows a scroll-to-latest button to re-engage. Call .ScrollAnchor() on a ChatMessage (typically the user's turn) to mark a turn boundary — the transcript settles that message near the top (with a configurable PreviousItemPeek) so the following reply grows into the screen below it. Busy(true/false) toggles aria-busy while a reply streams. ChatMessage content is wrapped in a DeltaComponent, so .ReplaceContent(...) can be called repeatedly to animate streamed/typed text.

Sample

API reference

class

ChatArea

public class ChatArea : IComponent

A chat transcript surface that lays out a sequence of messages with sender attribution, avatars and timestamps. It keeps streamed replies in view while the reader is at the live edge, stops following the moment the reader scrolls away, and offers a scroll-to-latest button to re-engage.

Namespace
Tesserae
Implements
IComponent

Constructors

NameDescription
ChatAreaInitializes a new instance of this class.
Constructor
ChatArea
public ChatArea()

Initializes a new instance of this class.

Properties

NameDescription
IsAtBottomGets whether the transcript is currently scrolled to (or within a few pixels of) the bottom.
IsFollowingOutputGets whether the transcript is currently following streamed output (auto-scrolling to the live edge).
Property
ChatArea.IsAtBottom
public bool IsAtBottom { get ; }

Gets whether the transcript is currently scrolled to (or within a few pixels of) the bottom.

Property
ChatArea.IsFollowingOutput
public bool IsFollowingOutput

Gets whether the transcript is currently following streamed output (auto-scrolling to the live edge).

Methods

NameDescription
OnScrollRegisters a callback invoked when the scroll event fires.
OnFocusRegisters a callback invoked when the focus event fires.
OnBlurRegisters a callback invoked when the blur event fires.
BackgroundGets or sets the CSS background of the component.
DefaultScrollPositionSets where the transcript settles when it is first populated (or re-populated after Clear).
PreviousItemPeekSets how many pixels of the previous turn stay visible above an anchored message when a new turn begins.
BusyToggles the aria-busy state on the transcript; set it while a turn is streaming so screen readers can defer announcements until the reply completes.
AddAdds the given item to the component.
PrependRangeInserts a batch of older messages at the top of the transcript while preserving the reader's current scroll position (so loading history above the fold does not move what they are reading).
RebuildPreservingScrollRuns a repopulation (typically Clear followed by a batch of Add calls) while preserving the reader's scroll position: if they were at the live edge it stays pinned to the bottom, otherwise their current position is restored so re-rendering the transcript does not yank them around.
ClearClears the component's current state.
ScrollToEndScrolls to the bottom of the transcript and re-engages following of streamed output.
ScrollToStartScrolls to the top of the transcript.
ScrollToMessageScrolls the message with the given identifier into view. Returns false if no such message is mounted.
RenderRenders the component's root HTML element.
Method
ChatArea.OnScroll
public ChatArea OnScroll(ComponentEventHandler<ChatArea, Event> onScroll)

Registers a callback invoked when the scroll event fires.

Method
ChatArea.OnFocus
public ChatArea OnFocus(ComponentEventHandler<ChatArea, Event> onFocus)

Registers a callback invoked when the focus event fires.

Method
ChatArea.OnBlur
public ChatArea OnBlur(ComponentEventHandler<ChatArea, Event> onBlur)

Registers a callback invoked when the blur event fires.

Method
ChatArea.Background
public ChatArea Background(string color)

Gets or sets the CSS background of the component.

Method
ChatArea.DefaultScrollPosition
public ChatArea DefaultScrollPosition(StartPosition position)

Sets where the transcript settles when it is first populated (or re-populated after Clear).

Method
ChatArea.PreviousItemPeek
public ChatArea PreviousItemPeek(int pixels)

Sets how many pixels of the previous turn stay visible above an anchored message when a new turn begins.

Method
ChatArea.Busy
public ChatArea Busy(bool isBusy)

Toggles the aria-busy state on the transcript; set it while a turn is streaming so screen readers can defer announcements until the reply completes.

Method
ChatArea.Add
public ChatArea Add(ChatMessage message)

Adds the given item to the component.

Method
ChatArea.PrependRange
public ChatArea PrependRange(IEnumerable<ChatMessage> older)

Inserts a batch of older messages at the top of the transcript while preserving the reader's current scroll position (so loading history above the fold does not move what they are reading).

Method
ChatArea.RebuildPreservingScroll
public ChatArea RebuildPreservingScroll(Action populate)

Runs a repopulation (typically Clear followed by a batch of Add calls) while preserving the reader's scroll position: if they were at the live edge it stays pinned to the bottom, otherwise their current position is restored so re-rendering the transcript does not yank them around.

Method
ChatArea.Clear
public ChatArea Clear()

Clears the component's current state.

Method
ChatArea.ScrollToEnd
public ChatArea ScrollToEnd(bool smooth = false)

Scrolls to the bottom of the transcript and re-engages following of streamed output.

Method
ChatArea.ScrollToStart
public ChatArea ScrollToStart(bool smooth = false)

Scrolls to the top of the transcript.

Method
ChatArea.ScrollToMessage
public bool ScrollToMessage(string identifier, bool smooth = true)

Scrolls the message with the given identifier into view. Returns false if no such message is mounted.

Method
ChatArea.Render
public HTMLElement Render()

Renders the component's root HTML element.

Events

NameDescription
ScrolledRaised when scrolled occurs.
ReceivedFocusRaised when received focus occurs.
LostFocusRaised when lost focus occurs.
Event
ChatArea.Scrolled
public event ComponentEventHandler<ChatArea, Event> Scrolled

Raised when scrolled occurs.

Event
ChatArea.ReceivedFocus
public event ComponentEventHandler<ChatArea, Event> ReceivedFocus

Raised when received focus occurs.

Event
ChatArea.LostFocus
public event ComponentEventHandler<ChatArea, Event> LostFocus

Raised when lost focus occurs.

class

ChatMessage

public class ChatMessage : IComponentWithID, IComponent
Namespace
Tesserae
Implements
IComponentWithID, IComponent

Constructors

NameDescription
ChatMessageInitializes a new instance of this class.
Constructor
ChatMessage
public ChatMessage(IComponent content, IComponent avatar = null, IComponent commands = null)

Initializes a new instance of this class.

Properties

NameDescription
IdentifierGets or sets the identifier.
ContentHashGets or sets the content hash.
BubbleBackgroundGets or sets the bubble background.
IsAnchorGets whether this message is a turn boundary that the transcript should settle near the top when a new turn begins.
Property
ChatMessage.Identifier
public string Identifier { get; private set; }

Gets or sets the identifier.

Property
ChatMessage.ContentHash
public string ContentHash { get; private set; }

Gets or sets the content hash.

Property
ChatMessage.BubbleBackground
public string BubbleBackground { get; private set; }

Gets or sets the bubble background.

Property
ChatMessage.IsAnchor
public bool IsAnchor { get; private set; }

Gets whether this message is a turn boundary that the transcript should settle near the top when a new turn begins.

Methods

NameDescription
AnimatedConfigures the component to animated.
ScrollAnchorMarks this message as a turn boundary. When it is added, the transcript treats it as the start of a new turn: it re-engages following and settles the message near the top of the viewport (with a peek of the previous turn above), so the reply that follows grows into the screen below it.
LeftAlignedConfigures the left aligned on the component.
RightAlignedConfigures the right aligned on the component.
FullWidthStretches the component to the full width of its parent.
MaxWidthGets or sets the CSS max-width of the component.
BackgroundGets or sets the CSS background of the component.
WithReferencesReturns the component configured with the given references.
ReplaceContentReplaces the content in the component.
KeepVisibleConfigures the keep visible on the component.
RenderRenders the component's root HTML element.
Method
ChatMessage.Animated
public ChatMessage Animated()

Configures the component to animated.

Method
ChatMessage.ScrollAnchor
public ChatMessage ScrollAnchor()

Marks this message as a turn boundary. When it is added, the transcript treats it as the start of a new turn: it re-engages following and settles the message near the top of the viewport (with a peek of the previous turn above), so the reply that follows grows into the screen below it.

Method
ChatMessage.LeftAligned
public ChatMessage LeftAligned()

Configures the left aligned on the component.

Method
ChatMessage.RightAligned
public ChatMessage RightAligned()

Configures the right aligned on the component.

Method
ChatMessage.FullWidth
public ChatMessage FullWidth()

Stretches the component to the full width of its parent.

Method
ChatMessage.MaxWidth
public ChatMessage MaxWidth()

Gets or sets the CSS max-width of the component.

Method
ChatMessage.Background
public ChatMessage Background(string color)

Gets or sets the CSS background of the component.

Method
ChatMessage.WithReferences
Overload
WithReferences(IEnumerable<IComponent>)Returns the component configured with the given references.
WithReferences(IComponent)Returns the component configured with the given references.
WithReferences(IEnumerable<IComponent>)
public ChatMessage WithReferences(IEnumerable<IComponent> references)

Returns the component configured with the given references.

Parameters

references IEnumerable<IComponent>
WithReferences(IComponent)
public ChatMessage WithReferences(IComponent reference)

Returns the component configured with the given references.

Parameters

reference IComponent
Method
ChatMessage.ReplaceContent
public ChatMessage ReplaceContent(IComponent newContent)

Replaces the content in the component.

Method
ChatMessage.KeepVisible
public void KeepVisible()

Configures the keep visible on the component.

Method
ChatMessage.Render
public HTMLElement Render()

Renders the component's root HTML element.

See also

© 2026 Curiosity. All rights reserved.