Skip to content

AI

AiScrollToLatest

Bit.BlazorUI.AI

BitAiScrollToLatest is the floating button that appears when the reader has scrolled away from the newest message of a transcript and takes them back to it. It renders only while Visible - there is somewhere to go - and floats centered above its nearest positioned ancestor, which in a BitAiChat is the footer, so it sits just above the composer whatever height the composer has. Pair it with the OnPinnedChange and ScrollToLatestAsync of a BitAiMessageList.

Notes

To use this component, you need to install the Bit.BlazorUI.AI(opens in a new tab) nuget package, as described in the Optional steps of the Getting started page.

The button decides nothing on its own: Visible says whether to show it and OnClick what pressing it does. BitAiChat wires both to its transcript for you; a chat assembled by hand wires them to a BitAiMessageList. It is positioned absolutely, so its container needs position: relative (or any other positioning) and room above it.

The button is a labelled BitButton (the ScrollToLatest string, "Scroll to latest", unless Label says otherwise), so it is reachable with the keyboard and named for a screen reader. Once pressed it goes away, as the view reaches the newest message, and the focus would go with it to the page: BitAiChat moves it to its composer, and a chat assembled by hand does the same in its OnClick (the FocusAsync of a BitAiPromptInput). Its entrance follows the motion tokens and is skipped under reduced motion, and it is left out of a printout.

Usage

Every example is live. Open its code to see exactly what produced the component running underneath.

Basic

Nothing is rendered until Visible is set; then the button floats centered above the box it is in, and OnClick reports a press.

The positioned box it floats above, such as the footer of a chat.

Pressed 0 times.

With a message list

What it is for: the OnPinnedChange of a BitAiMessageList shows it when the reader scrolls up, and its ScrollToLatestAsync takes them back. Scroll the transcript up.

Question 1: what happens at scale here?

Answer 1. The cost is dominated by rendering, not by parsing. Coalescing updates removes most of it, and virtualization removes the rest.

Demo Large180 tokensInput: 120 Output: 60
Question 2: what happens at scale here?

Here is the shape of it:

csharp
var budget = TimeSpan.FromMilliseconds(18);
scheduler.Request();

The interval is the only dial that matters.

Demo Large184 tokensInput: 122 Output: 62
Question 3: what happens at scale here?
Searched the documentation
scale 4
  • Render modes 94%
  • Circuit lifetime 81%

Two passages matched, and they say the same thing.

Demo Large188 tokensInput: 124 Output: 64
Question 4: what happens at scale here?
MessagesRenderedNotes
60allbelow the threshold
500visible onlyvirtualized
Sources
1
Performance notes
Internal wiki
Demo Large192 tokensInput: 126 Output: 66
Question 5: what happens at scale here?

Answer 5. The cost is dominated by rendering, not by parsing. Coalescing updates removes most of it, and virtualization removes the rest.

Demo Large196 tokensInput: 128 Output: 68
Question 6: what happens at scale here?

Here is the shape of it:

csharp
var budget = TimeSpan.FromMilliseconds(26);
scheduler.Request();

The interval is the only dial that matters.

Demo Large200 tokensInput: 130 Output: 70
Question 7: what happens at scale here?
Searched the documentation
scale 12
  • Render modes 94%
  • Circuit lifetime 81%

Two passages matched, and they say the same thing.

Demo Large204 tokensInput: 132 Output: 72
Question 8: what happens at scale here?
MessagesRenderedNotes
60allbelow the threshold
500visible onlyvirtualized
Sources
1
Performance notes
Internal wiki
Demo Large208 tokensInput: 134 Output: 74
Question 9: what happens at scale here?

Answer 9. The cost is dominated by rendering, not by parsing. Coalescing updates removes most of it, and virtualization removes the rest.

Demo Large212 tokensInput: 136 Output: 76
Question 10: what happens at scale here?

Here is the shape of it:

csharp
var budget = TimeSpan.FromMilliseconds(34);
scheduler.Request();

The interval is the only dial that matters.

Demo Large216 tokensInput: 138 Output: 78
The footer of the transcript.

Label

Label words the button in place of the string table's "Scroll to latest" - to say there are new messages, for instance.

Disabled

A disabled button is shown but takes no press.

Cascading parameters

BitParams with a BitAiScrollToLatestParams sets the label, the classes and the styles of every button inside it; a button's own value wins. Whether it is shown and what pressing it does are not cascaded. The label reaches the button of each BitAiChat in it too, while its classes and styles come from the chat's own Styles / Classes (their ScrollToLatest member).

Style & Class

Style / Class reach the root, Styles / Classes its Button (the class-styles of BitButton). The public --bit-AiScrollToLatest-* variables (see the CSS variables table) move it and lift it from :root, an ancestor or Style.

RTL

Use BitAiScrollToLatest in right-to-left (RTL).

CSS variables

The public custom properties this component reads off its root, for what no parameter covers.

Every variable is read with a fallback and never declared by the component, so it inherits like any other custom property: set one on :root (or in a [bit-theme] block) to restyle every instance, on any ancestor to restyle the ones inside it, or on the Style of one instance to restyle it - and any instance nested inside it, which inherits the value too; a parameter changes one alone, as does the real CSS property on the instance's Style / Styles when that property does not inherit (opacity: 1 keeps one disabled instance undimmed without undimming a disabled one inside it), while an inherited one such as color or font-family also reaches the nested instances that do not set it themselves. Leave a variable unset and the component falls back to the theme token beside it.

BitAiScrollToLatest CSS variables

Name Default value Description
--bit-AiScrollToLatest-offset spacing(1) Room between the button and the top edge of the positioned box it floats above.
--bit-AiScrollToLatest-shadow var(--bit-shd-popup) Elevation of the button over the transcript.
--bit-AiScrollToLatest-z-index 3 Stacking of the button over the transcript.

API

Every parameter, public member, sub-class and enum this component exposes.

BitAiScrollToLatest parameters

Name Type Default value Description
Classes BitAiScrollToLatestClassStyles? null Custom CSS classes for different parts of the scroll to latest.
Label string? null The text of the button, which is also its accessible name, in place of the ScrollToLatest of the string table ("Scroll to latest").
OnClick EventCallback The callback for when the button is pressed - typically the ScrollToLatestAsync of the BitAiMessageList it belongs to, then moving the focus to the composer, since the button goes away. Not raised while the button is disabled.
Styles BitAiScrollToLatestClassStyles? null Custom CSS styles for different parts of the scroll to latest.
Visible bool false Shows the button - while the reader is away from the newest message, so it never sits over the transcript doing nothing. Left unset, nothing is rendered.

BitComponentBase parameters

Name Type Default value Description
AriaLabel string? null Gets or sets the accessible label for the component, used by assistive technologies.
Class string? null Gets or sets the CSS class name(s) to apply to the rendered element.
Dir BitDir? null Gets or sets the text directionality for the component's content.
Disabled bool false Gets or sets a value indicating whether the component is disabled and cannot respond to user interaction.
ForceAnimation bool false Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested.
HtmlAttributes Dictionary<string, object> new Dictionary<string, object>() Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. An attribute written on the component wins over an entry of the same name.
Id string? null Gets or sets the unique identifier for the component's root element.
Style string? null Gets or sets the CSS style string to apply to the rendered element.
TabIndex string? null Gets or sets the tab order index for the component when navigating with the keyboard.
Visibility BitVisibility BitVisibility.Visible Gets or sets the visibility state (visible, hidden, or collapsed) of the component.

BitComponentBase public members

Name Type Default value Description
UniqueId Guid Guid.NewGuid() Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed.
RootElement ElementReference Gets the reference to the root HTML element associated with this component.

BitAiScrollToLatestClassStyles properties

Name Type Default value Description
Root string? null Custom CSS classes/styles for the root element of the BitAiScrollToLatest.
Button BitButtonClassStyles? null Custom CSS classes/styles for the button of the BitAiScrollToLatest.

BitVisibility enum

Name Value Description
Visible 0 The content of the component is visible.
Hidden 1 The content of the component is hidden, but the space it takes on the page remains (visibility:hidden).
Collapsed 2 The component is hidden (display:none).

BitDir enum

Name Value Description
Ltr 0 Ltr (left to right) is to be used for languages that are written from the left to the right (like English).
Rtl 1 Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic).
Auto 2 Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element.

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.