AiFileCard
Display a file in card form. Supports document/image/audio/video types, multiple sizes, loading state, and mask.
When to use
Use when displaying a single file in conversation or input scenarios, e.g. attachment lists or file previews in message bubbles.
Basic usage
Provide required name; optional props include byte, size, type, src. Cards use uniform width and height; long filenames are truncated with ellipsis; hover to see full name.
Card size
Set size to small, default, or large.
Image file
When type="image" and src is set, the card shows an image preview.
Image loading
Use the loading prop to show a loading state; the image stays visible but blurred with a spinner overlay, then transitions to clear when loading completes. The example below uses buttons to toggle between loading and complete.
Using mask
Use mask to show overlay text (e.g. "Encrypted") on the card.
Preset icon types
Use the icon prop with preset icons. Supported types: default, pdf, excel, word, ppt, image, markdown, zip, video, audio, java, javascript, python, txt. You can also omit icon and rely on extension-based inference.
Audio / Video
Aligns with Ant Design X FileCard: uses browser native <audio> / <video>; when src is provided, media is directly playable. For 3+ items, use traversal (v-for); the delete button removes the item. Without src, the preset icon placeholder is shown. Use audioProps / videoProps to extend native playback.
File list
Multiple file cards can be used with AiAttachments for list layout, overflow behavior, and delete. See AiAttachments.
API
FileCard Props
| Property | Description | Type | Default |
|---|---|---|---|
| name | File name (required) | string | - |
| byte | File size in bytes | number | - |
| size | Card size | 'small' | 'default' | 'large' | 'default' |
| type | File type | 'file' | 'image' | 'audio' | 'video' | string | 'file' |
| src | Image or file URL | string | - |
| description | Description | string | - |
| loading | Loading state | boolean | false |
| mask | Mask content | string | - |
| icon | Preset icon | PresetFileIcons | 'default' |
| imageProps | Image props (passed to img element) | Record<string, unknown> | {} |
| videoProps | Video props (passed to video element) | Record<string, unknown> | {} |
| audioProps | Audio props (passed to audio element) | Record<string, unknown> | {} |
| themeOverrides | Theme override variables | Record<string, unknown> | - |
Slots
| Slot | Description |
|---|---|
| default | Extension content (e.g. delete button, progress bar when used with AiAttachments) |
PresetFileIcons
Preset icon types:
default- Default file iconexcel- Excel file iconimage- Image file iconmarkdown- Markdown file iconpdf- PDF file iconppt- PowerPoint file iconword- Word file iconzip- Archive file iconvideo- Video file iconaudio- Audio file iconjava- Java file iconjavascript- JavaScript file iconpython- Python file icontxt- Text file icon
FileCardListItem
List item interface extends FileCardProps with additional properties:
| Property | Description | Type |
|---|---|---|
| uid | Unique identifier | string | number |
| url | File URL | string |
| thumbUrl | Thumbnail URL | string |
Events
| Event | Description |
|---|---|
| click | Fired when card is clicked (when not loading); for image type, clicking opens the preview |