Skip to content
Latestv1.0.63

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.

Basic usage

Placeholder ​

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

Placeholder

Drag and drop ​

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

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.

Delete

Multiple states ​

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

Multiple states

Overflow mode ​

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

Scroll X
Scroll Y
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
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.

Custom Upload

Monitor Upload Status via Events ​

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.