logoAnt Design X

DesignDevelopmentComponentsX MarkdownX SDKPlayground
  • Introduction
  • Overview
  • Common
    • Bubble
    • Conversations
    • Notification
  • Confirmation
    • Sources
    • Think
    • ThoughtChain
  • Wake
    • Welcome
    • Prompts
  • Express
    • Attachments
    • Sender
    • Suggestion
  • Feedback
    • Actions
    • FileCard
  • Others
    • XProvider

Attachments

Display the collection of attachment information.
Importimport { Attachments } from "@ant-design/x";
Sourcecomponents/attachments
Docs
Edit this page...
Changelog
loading

When To Use

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

Examples

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--
stylesCustom style object, see belowRecord<string, React.CSSProperties>--
imagePropsImage config, same as ImageImageProps--
tsx
interface PlaceholderType {
icon?: React.ReactNode;
title?: React.ReactNode;
description?: React.ReactNode;
}

Attachment

ts
interface Attachment extends UploadFile {
type?: 'image' | 'file' | 'other';
previewText?: React.ReactNode;
}

AttachmentsRef

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

Semantic DOM

Design Token

Component TokenHow to use?
Token NameDescriptionTypeDefault Value
colorBgPlaceholderHoverstringrgba(255,255,255,0.85)
Global TokenHow to use?
Basic

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

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Placeholder

Modify placeholder information.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Overflow

Controls the layout of attachments when they exceed the area.

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Combination

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

CodeSandbox Icon
codepen icon
External Link Icon
expand codeexpand code
Click or Drop files here
Support file type: image, video, audio, document, etc.
Custom Placeholder Node
Click or Drop files here
Support file type: image, video, audio, document, etc.
Attachments
Upload files
Click or drag files to this area to upload
Upload File
Drag or click to upload file.
  • root
    Root
  • placeholder
    Placeholder
  • root
    Root
  • list
    List container
  • card
    File Card
  • file
    File
  • icon
    File Icon
  • name
    File Name
  • description
    File Description
  • upload
    Upload Btn