Skip to content

AiAttachments

Used to display a set of attachment information. Supports click upload, drag-and-drop upload, and delete; works with AiFileCard for file cards.

When to use

Use when you need to display a set of attachments (e.g. uploading, uploaded, failed) with add/remove support, such as in AI input areas or form attachments.

Basic usage

Bind the attachment list with v-model:items; click to upload and delete. The list is rendered by traversal; for 3+ items each is shown as a card. For delete to work, remove the item in @delete-card (e.g. items.value.splice(index, 1)). Long names are truncated with ellipsis; hover to see full name.

document.pdf
100.0 KB
preview.png
50.0 KB
very-long-filename-for-overflow-test.xlsx
200.0 KB
Upload or drag files here
Supports images, documents, etc.
Basic usage

Placeholder

Configure the upload area with placeholder (icon, title, description). Supports object, function, or string shorthand.

document.pdf
100.0 KB
preview.png
50.0 KB
very-long-filename-for-overflow-test.xlsx
200.0 KB
Custom placeholder
PDF only
Placeholder

Drag and drop

Drop files onto the upload area to upload. Use getDropContainer to set the drop container (default is the component root).

document.pdf
100.0 KB
preview.png
50.0 KB
very-long-filename-for-overflow-test.xlsx
200.0 KB
Upload or drag files here
Supports images, documents, etc.
Drag and drop

Delete

Each card shows a delete button on hover; delete-card is emitted on click. For delete to take effect, remove the item in the callback (e.g. onDelete(_, index) { items.value.splice(index, 1) }); you can also use the callback for confirmation or server sync.

document.pdf
100.0 KB
preview.png
50.0 KB
very-long-filename-for-overflow-test.xlsx
200.0 KB
Upload or drag files here
Supports images, documents, etc.
Delete

Multiple states

Items support status: uploading (progress bar), done, error (red border + error text). Use percent, error, description for progress and messages.

uploading-file.xlsx
100.0 KB
93%
uploaded-file.docx
80.0 KB
Custom description
upload error with long name.zip
0 B
Server Error 500
preview.png
Upload or drag files here
Supports images, documents, etc.
Multiple states

Overflow mode

Use overflow to control layout: scrollX, scrollY, or wrap. Demos below use constrained width/height to show the effect.

document.pdf
100.0 KB
preview.png
50.0 KB
table.xlsx
50.0 KB
slides.pptx
300.0 KB
doc.docx
80.0 KB
archive.zip
1000.0 KB
Upload or drag files here
Supports images, documents, etc.
Scroll X
document.pdf
100.0 KB
preview.png
50.0 KB
table.xlsx
50.0 KB
slides.pptx
300.0 KB
doc.docx
80.0 KB
archive.zip
1000.0 KB
Upload or drag files here
Supports images, documents, etc.
Scroll Y
document.pdf
100.0 KB
preview.png
50.0 KB
table.xlsx
50.0 KB
slides.pptx
300.0 KB
doc.docx
80.0 KB
archive.zip
1000.0 KB
Upload or drag files here
Supports images, documents, etc.
Wrap

Upload Function

Basic Usage

The component has built-in upload flow. Click the upload button or drag files to trigger upload. The component will automatically:

  1. Create file list item (status: uploading)
  2. Emit upload-change event
  3. Call custom upload function httpRequest (if provided)
  4. Update status to done on success, emit upload-success
  5. Update status to error on failure, emit upload-error
Click or drag files to upload
Basic Usage

Custom Upload

Use httpRequest prop to fully customize upload logic (custom headers, URL, FormData handling, etc.). The function receives { file: File } parameter and must return a Promise.

Click or drag files to upload
Custom Upload

Monitor Upload Status via Events

Click or drag files to upload
Event Monitoring

API

Props

PropertyDescriptionTypeDefault
itemsAttachment listAttachmentItem[][]
overflowOverflow mode'wrap' | 'scrollX' | 'scrollY''scrollX'
scrollMaxHeightMax height when overflow is scrollY (e.g. 260px)string-
hideUploadHide upload buttonbooleanfalse
disabledDisabledbooleanfalse
maxCountMax file countnumber-
limitFile count limit (same as maxCount)number-
placeholderPlaceholder (object, function, or string)PlaceholderType | ((mode) => PlaceholderType) | string-
getDropContainerReturn the drop container element; default is component root() => HTMLElement-
beforeUploadPre-upload validation. Return false to cancel(file: File) => boolean | Promise<boolean>-
httpRequestCustom upload request function(options: { file: File }) => Promise<void>-
uploadIconSizeUpload button icon sizestring'24px'
dragTargetDrag target elementstring | HTMLElement-
listStyleList container styleRecord<string, string>{}
themeOverridesTheme override variablesRecord<string, unknown>-

AttachmentItem Extended Properties

In addition to FileCardListItem properties, attachment items support:

PropertyDescriptionTypeDefault
statusFile status'uploading' | 'done' | 'error' | 'removed'-
percentUpload progress (0-100)number-
responseResponse data after successful uploadunknown-
errorError messagestring-

Events

EventDescriptionParameters
update:itemsFired when list updates(items: AttachmentItem[])
upload-changeFired after file select/drop(file: File, fileList: AttachmentItem[])
upload-successFired after successful upload(response: unknown, file: File, fileList: AttachmentItem[])
upload-errorFired after upload failure(error: unknown, file: File, fileList: AttachmentItem[])
upload-dropFired on drag drop(files: File[])
delete-cardFired when item is deleted(item: AttachmentItem, index: number)
exceedFired when exceeding max count({ files, maxCount })

Slots

SlotDescription
defaultEntire component container content
file-itemCustom file card item, params: { item: AttachmentItem, index: number }
upload-buttonCustom upload button, params: { canUpload: boolean }
drop-areaCustom drop area content

Released under the MIT License.