Skip to content
# AiThinkingIndicator **Also known as:** TypingIndicator ## Description BitAiThinkingIndicator is shown while the model is working but has produced nothing yet: three bouncing dots and a label, drawn at the size of the text around it. It is a polite live region, so a screen reader user learns that a response is coming without the announcement interrupting them. The label says Thinking by default, or whatever the app knows about the wait - a tool that is running, a status the transport reported. ## Parameters | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Classes | `BitAiThinkingIndicatorClassStyles?` | null | Custom CSS classes for different parts of the thinking indicator. | | Label | `string?` | null | The text shown and announced beside the dots, for example the status of a running tool. Left null, the Thinking text of the BitAiStrings in force is shown. | | Styles | `BitAiThinkingIndicatorClassStyles?` | null | Custom CSS styles for different parts of the thinking indicator. | | 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. | ## 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. | ## Enums ### 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. | ## Sub Classes ### BitAiThinkingIndicatorClassStyles Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Root | `string?` | null | Custom CSS classes/styles for the root element of the BitAiThinkingIndicator. | | Loading | `BitLoadingClassStyles?` | null | Custom CSS classes/styles for the parts of the BitBouncingDotsLoading the BitAiThinkingIndicator draws: its root (the live region), its dots (Container, Child) and its label. | ## CSS Variables Public CSS custom properties read off the component's root. Set one on `:root` to restyle every instance, on any ancestor to restyle the ones inside it, or on the `Style` of one instance to restyle it and every instance nested inside it, which inherits the value too - a parameter changes one alone, as does the real CSS property on its `Style` / `Styles` when that property does not inherit (`opacity`); an inherited one (`color`, `font-family`) reaches the nested instances that do not set it themselves. | Name | Default Value | Description | | :--- | :------------ | :---------- | | `--bit-AiThinkingIndicator-color` | var(--bit-clr-fg-sec) | Color of the label. The dots keep the color of the loader (--bit-Loading-color). | | `--bit-AiThinkingIndicator-font-size` | var(--bit-tpg-fs-sm) | Size of the label, which the dots are drawn at too. | ## Examples \n**Basic**: ```razor ``` \n**Label**: ```razor ``` \n**While a reply is on its way**: ```razor @implements IAsyncDisposable Ask about the weather @if (session.Conversation.Messages.LastOrDefault(m => m.Role.IsAssistant) is { } reply) { @if (reply.PartsOf().Any(p => p.IsEmpty is false)) {
@reply.GetText()
} else if (session.IsGenerating) { } } ``` ```csharp [Inject] private IBitAiToolRegistry ToolRegistry { get; set; } = default!; private BitAiRenderScheduler sessionRenders = default!; private BitAiChatSession session = default!; protected override void OnInitialized() { // At most one render of the page per frame interval, however often the session changes. sessionRenders = new BitAiRenderScheduler(() => InvokeAsync(StateHasChanged)); // A scripted model that reports a status, calls get_weather and answers once the tool has returned. session = new BitAiChatSession( AiDemoToolTransports.CallsTool( "get_weather", """{"city":"Lisbon"}""", "It is 17 °C and clear in Lisbon - a good afternoon for a walk."), tools: ToolRegistry); session.StateChanged += sessionRenders.Request; } private Task AskAsync() => session.SubmitAsync("What is the weather like in Lisbon?"); // What the wait is about: the tool being called - from its first argument streaming in until it has run - else the // status the model reported, else the default text. private static string? WaitLabel(BitAiMessage reply) => reply.PartsOf().LastOrDefault() is { Status: BitAiToolCallStatus.Streaming or BitAiToolCallStatus.Pending or BitAiToolCallStatus.Running } call ? $"Calling the {call.Definition?.DisplayName ?? call.ToolName} tool" : reply.StatusText; public async ValueTask DisposeAsync() { await session.DisposeAsync(); await sessionRenders.DisposeAsync(); } ``` \n**Disabled**: ```razor ``` \n**Cascading parameters**: ```razor ``` ```csharp private readonly BitAiThinkingIndicatorParams[] thinkingParams = [ new() { Styles = new() { Root = "color: var(--bit-clr-pri)", Loading = new() { Label = "font-style: italic" } } }, ]; ``` \n**Style & Class**: ```razor
``` \n**RTL**: ```razor
``` ```csharp private readonly BitAiUiOptions persianOptions = BitAiUiOptions.Default with { Strings = new PersianAiStrings() }; // The default label, in Persian. private sealed class PersianAiStrings : BitAiStrings { public override string Thinking => "در حال فکر کردن"; } ```