Skip to content

FilesCard ๐Ÿ“‡ โ€‹

Introduction โ€‹

The FilesCard component is a flexible file display component that supports visual presentation of various file types (images, documents, compressed files, etc.), including file icons, names, descriptions, status and other information. It provides rich customization options and interactive features, suitable for file management, upload preview and other scenarios.

Code Examples โ€‹

Basic Usage โ€‹

Set name property, and name has no suffix. name="Test File"
Test File
Unknown
Set name property, has file suffix. name="Test File.pdf"
Test File
.pdf
Pdf
Supports matching built-in icons based on name suffix
Test doc suffix
.doc
Word
Test xls suffix
.xls
Excel
Test ppt suffix
.ppt
Ppt
Test txt suffix
.txt
Txt
Test pdf suffix
.pdf
Pdf
Test png suffix
.png
Image
Test jpg suffix
.jpg
Image
Test gif suffix
.gif
Image
Test mp4 suffix
.mp4
Video
Test mp3 suffix
.mp3
Audio
Test zip suffix
.zip
Zip
Test rar suffix
.rar
Zip
Test 7z suffix
.7z
Zip
Test lnk suffix
.lnk
Link
Test obj suffix
.obj
3D
Test fbx suffix
.fbx
3D
Test glb suffix
.glb
3D
Test sql suffix
.sql
Database
Test db suffix
.db
Database
Test md suffix
.md
Markdown
Test js suffix
.js
Code
Test py suffix
.py
Code
Test java suffix
.java
Code
Test php suffix
.php
Code
Test json suffix
.json
Code
If there is a suffix but can't match common icons, it defaults to File
https://dd.comMultiple special characters.suffix
.self
File

You can get the colorMap built-in file type fileType: color object on the component instance. Built-in 16 file type icons.

Status Setting โ€‹

Set status property to control file loading status "uploading","done","error"
uploading test file
.pdf
ไธŠไผ ไธญ...ใƒป0%
done test file
.pdf
Pdf
error test file
.pdf
ไธŠไผ ๅคฑ่ดฅ
"uploading"+"percent" controls upload progress, "error"+"errorTip" controls custom failure prompt
uploading test file
.doc
ไธŠไผ ไธญ...ใƒป50%
error test file
.doc
Custom failure prompt

Control file loading status (uploading, completed, failed) and progress display.

Display Delete Icon โ€‹

Delete test file
.md
Markdown

You can set the showDelIcon property to show the delete icon, and set the @delete method to handle the delete event.

Image File Display โ€‹

Image files previewable and non-previewable
Previewable image
.jpeg
Image
Non-previewable image
.jpeg
Image
Image files square variant other formats are not affected by variant property
Other files not affected by variant
.txt
Txtใƒป29 KB
Image files default rectangle variant supports upload status, supports preview on/off, supports preview mask overlay on/off
Upload progress
.jpeg
ไธŠไผ ไธญ...ใƒป50%
Upload failed
.jpeg
ไธŠไผ ๅคฑ่ดฅ
Close preview hover mask
.jpeg
Image
Close preview function
.jpeg
Image
Image files square variant supports upload status, supports preview on/off, supports preview mask overlay on/off
50%
ไธŠไผ ๅคฑ่ดฅ

Supports image preview, square/rectangle variants, upload status overlay and other features. Can also be controlled through status and percent.

Custom Styles and Interaction โ€‹

Custom style
.xls
Excel
Custom hoverStyle
.xls
Excel

Customize card styles via style/hoverStyle, supports hover delete icon and custom slot extension.

Custom Built-in File Colors โ€‹

Custom Colors 1

Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description

Custom Colors 2

Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description
Test Name
Test description

Properties โ€‹

Property NameTypeRequiredDefaultDescription
uidstring | numberNoundefinedFile unique identifier
namestringNoundefinedFile name (supports automatic suffix parsing to match icons)
fileSizenumberNoundefinedFile size (unit: bytes, automatically converted to readable format)
fileTypestringNoundefinedFile type (priority higher than name suffix parsing, e.g. 'image', 'document')
descriptionstringNoundefinedDescription text (supports dynamic generation of file type and size info)
urlstringNoundefinedFile access URL (image files can be used for preview)
thumbUrlstringNoundefinedImage thumbnail URL
imgFileFile | BlobNoundefinedImage file stream (automatically parsed as preview URL, only for temporary display before upload)
iconSizestringNo'42px'Icon/image size
iconColorstringNoundefinedIcon color for non-image files (supports custom color values)
showDelIconbooleanNofalseWhether to show hover delete icon
maxWidthstringNo'236px'Card maximum width
styleCSSPropertiesNoundefinedCard custom styles
hoverStyleCSSPropertiesNoundefinedCard custom styles when hovering
imgVariant'rectangle' | 'square'No'rectangle'Image card form (rectangle/square)
imgPreviewbooleanNotrueWhether to enable image preview functionality
imgPreviewMaskbooleanNotrueWhether to show image preview mask overlay
status'uploading' | 'done' | 'error'NoundefinedFile status (controls progress bar, error prompts and other visual feedback)
percentnumberNo0Upload progress percentage (used with status="uploading")
errorTipstringNo'Upload failed'Custom error status prompt text

Slots โ€‹

Slot NameSlot ParametersDescription
#icon{ item: FilesCardProps }Custom icon area (priority higher than auto-parsed built-in icons)
#content{ item: FilesCardProps }Custom content area (overrides default name and description display)
#name-prefix{ item: FilesCardProps, prefix, suffix }Custom file name prefix (for truncation display scenarios)
#name-suffix{ item: FilesCardProps, prefix, suffix }Custom file name suffix (for truncation display scenarios)
#description{ item: FilesCardProps, prefix, suffix }Custom description text (overrides default generated description)
#image-preview-actions{ item: FilesCardProps, prefix, suffix }Image preview mask content (displayed on hover, requires imgPreviewMask)
#del-icon{ item: FilesCardProps }Custom delete icon (default uses Element Plus CircleCloseFilled icon)

Events โ€‹

Event NameCallback ParametersDescription
delete{ ...props }Triggered when delete button is clicked, passes complete properties of current card
image-preview{ ...props }Called when image preview function is triggered (click image or mask layer)

Features โ€‹

  1. Automatic File Type Recognition Automatically matches built-in icons based on file name suffixes (supports common formats like .pdf, .png, .zip, etc.), displays generic file icon when no match is found.
  2. Multi-state Visualization Supports uploading (uploading with progress bar), done (completed), error (failed with custom prompt) three states, state styles automatically switch.
  3. Enhanced Image File Support Supports image preview functionality (based on Element Plus image preview component), provides square/rectangle variants, supports direct parsing of local image file streams through imgFile.
  4. Highly Customizable Custom icon colors, sizes, card styles and hover effects, flexibly extend content through slots (such as file name truncation display, status overlay).
  5. Responsive Design Supports controlling card maximum width through maxWidth, adapts to different layout scenarios, file descriptions automatically truncate to prevent overflow.