logoAnt Design X

Attachments

Display the collection of attachment information.
Import
import{ Attachments }from"@ant-design/x";

When To Use

The Attachments component is used in scenarios where a set of attachment information needs to be displayed.

Examples

Basic usage. You can use getDropContainer to support drag and drop upload.

codepen icon
External Link Icon
expand codeexpand code
Click or Drop files here
Support file type: image, video, audio, document, etc.
Custom Placeholder Node

Modify placeholder information.

codepen icon
External Link Icon
expand codeexpand code
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

Controls the layout of attachments when they exceed the area.

codepen icon
External Link Icon
expand codeexpand code
Attachments
Upload files
Click or drag files to this area to upload

Work with Sender.Header to insert file into the conversation.

codepen icon
External Link Icon
expand codeexpand code
excel-file
.xlsx
109 KB
word-file
.docx
217 KB
image-file
.png
326 KB
pdf-file
.pdf
434 KB
ppt-file
.pptx
543 KB
video
video-file
.mp4
651 KB
audio
audio-file
.mp3
760 KB
zip-file
.zip
868 KB
markdown-file
.md
Custom description here
preview
Preview

A single file card, used in some display scenarios.

codepen icon
External Link Icon
expand codeexpand code

API

AttachmentsProps

For more properties, see Upload.

PropertyDescriptionTypeDefaultVersion
classNamesCustom class names, see belowRecord<string, string>--
disabledWhether to disablebooleanfalse-
getDropContainerConfig the area where files can be dropped() => HTMLElement--
itemsAttachment list, same as Upload fileListAttachment[]--
overflowBehavior when the file list overflows'wrap' | 'scrollX' | 'scrollY'--
placeholderPlaceholder information when there is no filePlaceholderType | ((type: 'inline' | 'drop') => PlaceholderType)--
rootClassNameRoot node classNameReact.CSSProperties--
rootStyleRoot node style objectReact.CSSProperties--
stylesCustom style object, see belowRecord<string, React.CSSProperties>--
imagePropsImage config, same as ImageImageProps--
interface PlaceholderType {
icon?: React.ReactNode;
title?: React.ReactNode;
description?: React.ReactNode;
}

AttachmentsRef

PropertyDescriptionTypeVersion
nativeElementGet the native nodeHTMLElement-
uploadManually upload a file(file: File) => void-

Attachments.FileCard Props

PropertyDescriptionTypeDefaultVersion
prefixClsThe prefix of the style class namestring--
classNameStyle class namestring--
styleStyle ObjectReact.CSSProperties--
itemAttachment, same as Upload UploadFileAttachment--
onRemoveA callback function, will be executed when removing file button is clicked, remove event will be prevented when the return value is false or a Promise which resolve(false) or reject(item: Attachment) => boolean | Promise--
imagePropsImage config, same as ImageImageProps--

Semantic DOM

Upload File
Drag or click to upload file.
  • placeholder
    Placeholder
preview
Preview
preview
Preview
preview
Preview
  • list
    List container
  • item
    List item

Design Token

Ask me