2.10.0
中文
Skip to content

Attachments ​

Used to display a collection of attachment information.

When to use ​

The Attachments component is used in scenarios where there is a need to display a set of attachment information.

Examples ​

Basic ​

Placeholder ​

Click or Drop files here
Support file type: image, video, audio, document, etc.
Custom Placeholder Node
Placeholder

Customize the placeholder.

Overflow style ​

preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
preview
Preview
Overflow style

Control how attachments overflow.

Combined example ​

Select files by type ​

File card ​

Custom card icon ​

API ​

General properties reference: General Properties.

Attachments Props ​

Inherits antdv Upload properties.

PropDescriptionTypeDefaultVersion
classNamesCustom style class names, see belowRecord<string, string>--
disabledWhether disabledbooleanfalse-
getDropContainerSet the area where the file can be released when dragging() => HTMLElement--
itemsattachment list, same as Upload fileListAttachment[]--
overflowStyle when the file list exceeds'wrap' | 'scrollX' | 'scrollY'--
placeholderPlaceholder information when there is no filePlaceholderType | ((type: 'inline' | 'drop') => PlaceholderType)--
rootClassNameRoot class namestring--
rootStyleRoot style objectCSSProperties--
stylesCustom style object, see belowRecord<string, CSSProperties>--
imagePropsImage properties, same as antdv Image propertiesImageProps--
tsx
interface PlaceholderType {
  icon?: VNode;
  title?: VNode | string;
  description?: VNode | string;
}

Attachments Slots ​

SlotDescriptionType
placeholderPlaceholder information when there is no file{ type: "inline" | "drop" }

Attachments Expose ​

PropDescriptionTypeVersion
nativeElementGet native nodeHTMLElement-
fileNativeElementGet the native input node for file uploadHTMLInputElement | null-
uploadManually call to upload files(file: File | File[] | FileList) => void-
selectManually open the file selector (can override accept / multiple)(options: { accept?: string; multiple?: boolean }) => void-

Attachments.FileCard Props ​

PropDescriptionTypeDefaultVersion
itemAttachment, same as Upload UploadFileAttachment--
onRemoveCallback when clicking to remove a file. If the return value is false, the file will not be removed. It also supports returning a Promise object; if the Promise resolves with false or rejects, the file will not be removed(item: Attachment) => booleanPromise-
iconCustom iconVNodePresetIcons-
typeDefines the file type. When the type is image, it will display in image preview mode'file''image'file
ts
type PresetIcons = 'default' | 'excel' | 'image' | 'markdown' | 'pdf' | 'ppt' | 'word' | 'zip' | 'video' | 'audio';

Semantic DOM ​

Upload File
Drag or click to upload file.
  • placeholder
    占位符
preview
Preview
preview
Preview
preview
Preview
  • list
    列表容器
  • item
    列表项
  • upload
    上传按钮

The semantic keys for Vue Attachments classNames / styles are list / item / placeholder / upload (different from some FileCard semantics in React 2.10, here only records the keys actually exposed by Vue).

Design Token ​

TokenDescriptionTypeDefault
colorBgPlaceholderHoverBackground color on placeholder hoverstringrgba(colorBgContainer, 0.85)

Contributors ​

Contributors

Loading contributors…