AI
AiAttachmentChip
BitAiAttachmentChip shows one BitAiAttachment as a chip - a BitTag: a thumbnail for an image and the glyph of its kind for anything else, its name, and under it its size, the progress of an upload still arriving, or why the upload failed. Its dismiss button removes the attachment, there only while OnRemove is set. The composer stages files as these chips, and a message shows its files with them.
Notes
Usage
Every example is live. Open its code to see exactly what produced the component running underneath.
Basic
Kinds
aurora.jpg1.8 MBImage policy
aurora.jpg1.8 MBStatus
OnRemove
aurora.jpg1.8 MBDisabled
Cascading parameters
aurora.jpg1.8 MBStyle & Class
aurora.jpg1.8 MB
aurora.jpg1.8 MBRTL
شفق-قطبی.jpg1.8 MBCSS 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.
BitAiAttachmentChip CSS variables
| Name | Default value | Description |
|---|---|---|
| --bit-AiAttachmentChip-max-width | spacing(32) | Widest the chip gets before its name is cut short. |
| --bit-AiAttachmentChip-thumbnail-size | spacing(4.25) | Width and height of the thumbnail of an image, and of the box holding the glyph of any other file. |
| --bit-AiAttachmentChip-thumbnail-radius | var(--bit-shp-radius-sm) | Corner of the thumbnail. |
| --bit-AiAttachmentChip-thumbnail-background | var(--bit-clr-bg-sec) | Fill behind the glyph, or behind a picture that does not cover its box. |
| --bit-AiAttachmentChip-thumbnail-color | var(--bit-clr-fg-sec) | Color of the glyph shown in place of a picture. |
API
Every parameter, public member, sub-class and enum this component exposes.
BitAiAttachmentChip parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| Attachment | BitAiAttachment | The attachment to show: its Name, its Kind (the thumbnail or glyph before the name) and, under the name, its Size, its upload Progress or its Error, as its Status says. Required. | |
| Classes | BitAiAttachmentChipClassStyles? | null | Custom CSS classes for different parts of the attachment chip. |
| OnRemove | EventCallback<BitAiAttachment> | Raised with the attachment when the user removes it. The remove button - the dismiss button of the tag, named Remove and the file name - is there only while this is set. | |
| Styles | BitAiAttachmentChipClassStyles? | null | Custom CSS styles for different parts of the attachment chip. |
BitAiAttachmentChip public members
| Name | Type | Default value | Description |
|---|---|---|---|
| FocusAsync | ValueTask | Gives the keyboard focus to the remove button of the chip - what a row of chips hands the focus on with after removing one, since the button that was pressed goes with its chip. A chip without OnRemove has no button and nothing to focus. |
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. |
BitAiAttachmentChipClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitAiAttachmentChip. |
| Tag | BitTagClassStyles? | null | Custom CSS classes/styles for the BitTag of the BitAiAttachmentChip that carries the name, the details and the remove button. |
| Thumbnail | string? | null | Custom CSS classes/styles for the thumbnail of the BitAiAttachmentChip: the picture of an image, or the box holding the glyph of any other kind of file. |
| Icon | string? | null | Custom CSS classes/styles for the glyph of the BitAiAttachmentChip shown in place of a picture. |
BitAiAttachment properties
A file carried by a message or staged in the composer: new BitAiAttachment(attachmentId, name) { ... }. It holds no byte array of its own, so Blazor Server never keeps a multi-megabyte upload in circuit memory: its content is referenced through Url, Data or ContentFactory and only read when something needs it.
| Name | Type | Default value | Description |
|---|---|---|---|
| AttachmentId | string | An identifier unique within its message or composer, a good @key. Required; it cannot be empty. | |
| Name | string | The file name shown to the user. | |
| ContentType | string? | null | The MIME type, for example image/png. |
| Size | long? | null | The size in bytes, when known. The chip shows it, formatted (FormatBytes of the strings in force), once the file is ready. |
| Kind | BitAiAttachmentKind | BitAiAttachmentKind.File | The category that decides the preview: a thumbnail for an image, the glyph of its kind otherwise. InferKind works it out of a MIME type and a file name. |
| Status | BitAiAttachmentStatus | BitAiAttachmentStatus.Ready | Where the upload of the file is. |
| Progress | double? | null | The progress of the upload, from 0 to 1, while the Status is Uploading. |
| Error | string? | null | Why the upload failed, when the Status is Failed. When null, the UploadFailed text of the strings in force is shown. |
| Url | string? | null | An addressable URL for the content, which may be a data URL for a small inline file. The chip shows it for an image without a ThumbnailUrl. |
| ThumbnailUrl | string? | null | A URL for a small preview image, distinct from the full-size content, which the chip prefers for an image. |
| Data | ReadOnlyMemory<byte>? | null | Inline bytes, for small attachments that are cheap to keep in memory. |
| ContentFactory | Func<CancellationToken, ValueTask<Stream>>? | null | Opens the content on demand. Preferred over Data for anything large; never serialized. |
| Metadata | IReadOnlyDictionary<string, object?>? | null | App-defined values carried through to custom attachment renderers. |
| HasInlineData | bool | false | Whether the content can be read without a round trip (Data is set). |
| OpenReadAsync(CancellationToken cancellationToken) | ValueTask<Stream> | Opens the content from whichever source there is: the ContentFactory, else the Data. Throws an InvalidOperationException for an attachment carrying neither. | |
| InferKind(string? contentType, string? fileName) | static BitAiAttachmentKind | Infers the kind from a MIME type (image/*, audio/*, video/*, application/pdf), or from the extension of the file name when the type is missing or generic. |
BitAiAttachmentKind enum
| Name | Value | Description |
|---|---|---|
| File | 0 | Anything without a more specific category. The chip shows the glyph of a page. |
| Image | 1 | A raster or vector image. The chip shows its ThumbnailUrl, else its Url, where the image policy shows it outright, and the glyph of a picture otherwise. |
| Audio | 2 | An audio clip. The chip shows the glyph of a microphone. |
| Video | 3 | A video clip. The chip shows the glyph of a video camera. |
| Document | 4 | A PDF or other paginated document. The chip shows the glyph of a page, as for any other file. |
BitAiAttachmentStatus enum
| Name | Value | Description |
|---|---|---|
| Pending | 0 | Selected locally and not yet uploaded. The chip shows the size, as it does once the file is ready. |
| Uploading | 1 | Upload in progress. The chip shows the Progress as a percentage (0% while it is null). |
| Ready | 2 | Available to the model. The chip shows the size, when it is known. |
| Failed | 3 | The upload failed. The chip shows the Error (the UploadFailed text of the strings in force when it is null) in the error color. |
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.