Skip to content

Upload ​

File field with a button trigger and a text list. Picture cards and a drag zone are opt-in. Progress uses brand gold. Success and failure use an icon plus text.

The built-in transport simulates progress so a demo can finish without an endpoint. Pass customRequest for a real upload. Cropping and a preview lightbox are follow-ups.

Demos ​

List

Default list-type is list. Default dragger is false. Sizes are 28 / 34 / 40.

Drag zone

Picture card

Sizes, max, disabled

Inside a form item

API ​

Properties ​

NameTypeDefaultNotes
value / file-listUploadFile[][]{ id, name, size?, status, percent?, url?, thumbnailUrl?, file? }
acceptstring''Forwarded to the hidden file input
multiplebooleanfalseWhen false, a new pick replaces the list
maxnumber—Disables the trigger and shows「已達上限」
sizesm | md | lgmdButton height 28 / 34 / 40. Cards are 96 / 104 / 112
list-typelist | picture-cardlist
show-file-listbooleantrue
show-remove-button / show-retry-buttonbooleantrue
draggerbooleanfalseDashed drop zone instead of the button
directorybooleanfalseSets webkitdirectory
namestring'file'FormData field name
default-uploadbooleantruefalse leaves files pending until upload()
customRequestfunction—{ file, fileItem, onProgress, onSuccess, onError }
beforeUploadfunction—Return false or throw to cancel. before-upload is also cancelable

status is pending | uploading | success | error.

Events ​

NameDetail
change, update:file-list, update:value{ fileList, value }
before-upload{ file } — preventDefault() cancels
progress{ file, percent }
success{ file, response? }
error{ file, error? }
remove{ file }
retry{ file }
preview{ file } — picture-card only. No lightbox in v1

Parts ​

root, trigger, input, dragger, list, item, thumbnail, name, size, progress, status-icon, remove, retry, add.

Slots ​

trigger replaces the button or drag zone. file replaces the list. empty is an optional hint when the list is empty.

Set show-file-list="false", default-upload="false", or show-search style flags with the string false. A bare attribute means true.