Skip to content
# AiSourceList ## Description BitAiSourceList is the deduplicated list of the sources a message cited, each a BitAiSourceCard numbered to match the inline citation markers, laid out as a responsive grid under a small Sources heading. A source cited several times is listed once, under the lowest number any of its citations carries, and the list is ordered by those numbers - a source cited without a number goes last. Nothing is rendered while there is nothing to list. A message renders one under its text when it cites anything (BitAiUiOptions.ShowSourceList). ## Parameters | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Citations | `IReadOnlyList<BitAiCitation>?` | null | The citations to list the sources of - usually the Citations of a message. A source is listed once (by its SourceId), under the lowest Number any of its citations carries, ordered by those numbers; a source cited without a number goes last. Nothing is rendered while there is none. | | Classes | `BitAiSourceListClassStyles?` | null | Custom CSS classes for different parts of the source list. | | OnSourceClick | `EventCallback<BitAiCitationSource>` | | The callback for when the user activates a source card, with its source. When set, the cards become buttons instead of links - for revealing the source in place. A disabled list hands over nothing. | | ShowHeading | `bool` | true | Shows the heading (BitAiStrings.Sources, "Sources") above the cards, which names the list for assistive technologies. Left out, the list is named by the same words all the same. | | Styles | `BitAiSourceListClassStyles?` | null | Custom CSS styles for different parts of the source list. | | 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 ### BitAiSourceListClassStyles Properties | Name | Type | Default Value | Description | | :--- | :--- | :------------ | :---------- | | Root | `string?` | null | Custom CSS classes/styles for the root element of the BitAiSourceList. | | Header | `string?` | null | Custom CSS classes/styles for the heading of the BitAiSourceList. | | List | `string?` | null | Custom CSS classes/styles for the list (the grid of the cards) of the BitAiSourceList. | | SourceCard | `BitAiSourceCardClassStyles?` | null | Custom CSS classes/styles for every BitAiSourceCard of the BitAiSourceList. | ## 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-AiSourceList-gap` | spacing(1) | Room between the heading and the cards, and between two cards. | | `--bit-AiSourceList-column-min-width` | spacing(26) | Width a column of cards does not shrink below, which decides how many columns fit; 100% stacks the cards. | | `--bit-AiSourceList-header-color` | var(--bit-clr-fg-sec) | The heading. | | `--bit-AiSourceList-header-font-size` | var(--bit-tpg-fs-xs) | Size of the heading, which is cased and tracked like the overline style of the theme. | ## Examples \n**Basic**: ```razor ``` ```csharp private static readonly BitAiCitationSource renderModesSource = new("render-modes", "Blazor render modes") { Kind = BitAiSourceKind.Web, Url = "https://learn.microsoft.com/aspnet/core/blazor/components/render-modes", SiteName = "Microsoft Learn", Description = "How interactivity is chosen per component or per page.", }; private static readonly BitAiCitationSource circuitsSource = new("circuits", "SignalR circuit lifetime") { Kind = BitAiSourceKind.Document, Url = "https://learn.microsoft.com/aspnet/core/blazor/fundamentals/signalr", SiteName = "Microsoft Learn", Description = "What happens to state when a circuit drops.", }; private static readonly BitAiCitation[] citations = [ new("c1", renderModesSource) { Number = 1 }, new("c2", circuitsSource) { Number = 2 }, ]; ``` \n**Deduplication & order**: ```razor ``` ```csharp // renderModesSource and circuitsSource are the sources of the Basic example. private static readonly BitAiCitationSource reportSource = new("q3-report", "Q3 report.pdf") { Kind = BitAiSourceKind.File }; private static readonly BitAiCitation[] mixedCitations = [ new("c1", circuitsSource) { Number = 2 }, new("c2", renderModesSource) { Number = 1 }, new("c3", circuitsSource) { Number = 3, Quote = "Another passage of the same document." }, new("c4", reportSource), ]; ``` \n**Heading**: ```razor ``` \n**Source click**: ```razor
Clicked: @(clicked?.Title ?? "-") @clicked?.Description
``` ```csharp private BitAiCitationSource? clicked; ``` \n**From a message**: ```razor @implements IAsyncDisposable Ask @if (citedMessage is not null) {
@citedMessage.GetText()
} ``` ```csharp // AiDemoContentTransports.Cited is a scripted transport of this site whose answer cites two sources: // https://github.com/bitfoundation/bitplatform/blob/develop/src/BlazorUI/Demo/Client/Bit.BlazorUI.Demo.Client.Core/Services/AI/AiDemoContentTransports.cs private BitAiChatSession? citedSession; private BitAiMessage? citedMessage; private bool isAsking; private async Task AskCited() { isAsking = true; if (citedSession is not null) await citedSession.DisposeAsync(); citedSession = new BitAiChatSession(AiDemoContentTransports.Cited()); citedMessage = await citedSession.SubmitAsync("What does Interactive Server trade away?"); isAsking = false; } public async ValueTask DisposeAsync() { if (citedSession is not null) await citedSession.DisposeAsync(); } ``` \n**Disabled**: ```razor
Clicked: @(disabledClicked?.Title ?? "-")
``` ```csharp // citations is the list of the Basic example. private BitAiCitationSource? disabledClicked; ``` \n**Cascading parameters**: ```razor ``` ```csharp // citations is the list of the Basic example. private readonly BitAiSourceListParams[] listParams = [ new() { ShowHeading = false, Styles = new() { SourceCard = new() { Title = "font-weight: 600" } } } ]; ``` \n**Style & Class**: ```razor ``` \n**RTL**: ```razor ``` ```csharp private static readonly BitAiCitation[] rtlCitations = [ new("c1", new BitAiCitationSource("render-modes", "حالت‌های رندر بلیزر") { Kind = BitAiSourceKind.Web, Url = "https://learn.microsoft.com/fa-ir/aspnet/core/blazor/components/render-modes", SiteName = "مایکروسافت لرن", }) { Number = 1 }, new("c2", new BitAiCitationSource("circuits", "طول عمر اتصال SignalR") { Kind = BitAiSourceKind.Document, Url = "https://learn.microsoft.com/fa-ir/aspnet/core/blazor/fundamentals/signalr", SiteName = "مایکروسافت لرن", }) { Number = 2 }, ]; ```