Participate in the WeaveFox "AI Artist" contest to win SEE Conf tickets and thousands of prizes

logoAnt Design X

DesignDevelopmentComponentsX MarkdownX SDKPlayground
  • Introduction
  • Overview
  • Common
    • Bubble
    • Conversations
    • Notification
  • Wake
    • Welcome
    • Prompts
  • Express
    • Attachments
    • Sender
    • Suggestion
  • Confirmation
    • Sources
    • Think
    • ThoughtChain
  • 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 collection of attachment information needs to be displayed.

Examples

API

Common props ref: Common props.

AttachmentsProps

Inherits antd Upload properties.

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 classNamestring--
stylesCustom style object, see belowRecord<string, React.CSSProperties>--
imagePropsImage config, same as antd ImageImageProps--
tsx
interface PlaceholderType {
icon?: React.ReactNode;
title?: React.ReactNode;
description?: React.ReactNode;
}
### AttachmentsRef
| Property | Description | Type | Version |
| ------------- | ---------------------- | -------------------- | ------- |
| nativeElement | Get the native node | HTMLElement | - |
| fileNativeElement | Get the file upload native node | HTMLElement | - |
| upload | Manually upload a file | (file: File) => void | - |
| select | Manually select files | (options: { accept?: string; multiple?: boolean; }) => void | - |
## Semantic DOM
<code src="./demo/_semantic.tsx" simplify="true"></code>
## Design Token
<ComponentTokenTable component="Attachments"></ComponentTokenTable>
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
Select Files by Type

Calling the ref.select method can open the file selection dialog to upload files by type. Setting multiple to true enables multi-selection, and setting maxCount can limit the maximum number of files that can be selected.

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
Attachments
Upload files
Click or drag files to this area to upload