JGuang

Transfer

Transfer · Arco Design

Preview
npm install @arco-design/web-react@2.66.18

Transfer

A two-column multi-select component that moves elements from one column to another in real time.

Install

npm install @arco-design/web-react@2.66.18

Import @arco-design/web-react/dist/css/arco.css at the entry and set the locale with ConfigProvider. React 19 projects must also import @arco-design/web-react/es/_util/react-19-adapter first, or imperative APIs such as Message and Modal cannot render.

Examples

  • Basic: A two-column multi-select component that moves elements from one column to another in real time.
  • With Search Box: Specify showSearch to use the Transfer with search box.
  • One Way: Specify oneWay to only allow one-way movement
  • Advanced: Advanced usage of shuttle frame, configurable operation copy, and customizable width and height.
  • Pagination: When the amount of data is large, specify pagination to display the data in pages.
  • Custom Render: Custom rendering of each item through render.
  • With Table: Use Table component as a custom rendering list.
  • With Tree: Use Tree component as a custom rendering list.
  • Simple Mode: Specify simple to turn on simple mode, click the option to move. Additional configuration simple = { retainSelectedItems: true } to keep selected items on the left.
  • Drag: Specify draggable as true, and the left and right panels can be sorted by dragging.
  • Custom-Header: Pass render functions to titleTexts to completely customize the title bar of the Transfer. The parameter received by the function is { countTotal: number; countSelected: number; checkbox: ReactNode; clear: () => void }.

Examples come from the official Arco Design repository (MIT) at the commit published as npm 2.66.18. Some use online images or upload endpoints; network requests are disabled in previews.

API

Transfer

PropertyDescriptionTypeDefaultValueVersion
disabledWhether is disabledboolean--
draggableWhether the items in the list can be draggedboolean--
oneWayWhether to allow only one-way movementboolean--
onChangeCallback when the transfer between columns is complete(newTargetKeys: string[], direction: 'source' | 'target', moveKeys: string[]) => void--
onSearchCallback when value of search box is changed(value: string, type?: 'source' | 'target') => void--
classNameAdditional css classstring | string[]--
dataSourceUsed for setting the source dataTransferItem[]--
defaultSelectedKeysInitial set of keys of selected itemsstring[][]-
defaultTargetKeysInitial set of keys of items that are listed on the target columnstring[][]-
listStyleThe additional css style of columns, pass in different properties for lists through arrayCSSProperties | CSSProperties[]-Array format in '2.40.0'
onDragEndCallback when the user has finished dragging a transfer item(e: DragEvent<HTMLSpanElement>, item: TransferItem) => void--
onDragLeaveCallback when a draggable item leaves a valid drop target(e: DragEvent<HTMLSpanElement>, item: TransferItem) => void--
onDragOverCallback when a draggable item is being dragged over a valid drop target(e: DragEvent<HTMLSpanElement>, item: TransferItem) => void--
onDragStartCallback when user start to drag a transfer item(e: DragEvent<HTMLSpanElement>, item: TransferItem) => void--
onDropCallback when draggable item is dropped in a <div> element(info: {e: DragEvent<HTMLSpanElement>;dragItem: TransferItem;dropItem: TransferItem;dropPosition: number;}) => void--
operationStyleThe additional css style of operation buttonsCSSProperties--
operationTextsTexts of buttons that are used to transfer itemstring[] | ReactNode[]--
paginationWhether to divide into pages, you can also pass in the configuration of Pagination, pass in different properties for lists through arrayboolean | PaginationProps | Array<boolean | PaginationProps>-Array format in '2.40.0'
searchPlaceholderPlaceholder of search box, pass in different properties for lists through arraystring | string[]-Array format in '2.40.0'
selectedKeysSet of keys of selected itemsstring[]--
showFooterWhether to display the reset-button in columns, pass in different properties for lists through arrayboolean | ReactNode | Array<boolean | ReactNode>-ReactNode in 2.11.0, array format in '2.40.0'
showSearchWhether to display the search box in columns, pass in different properties for lists through arrayboolean | InputProps | Array<boolean | InputProps>-Array format in '2.40.0'
simpleWhether to automatically move an item when it is selected| boolean| {retainSelectedItems?: boolean;}-retainSelectedItems in '2.21.0'
styleAdditional styleCSSProperties--
targetKeysSet of keys of items that are listed on the target columnstring[]--
titleTextsTitle list of Transfer columns. (2.18.0 began to support function)Array<TransferListTitle>['Source', 'Target']-
virtualListPropsPass properties used by VirtualList.AvailableVirtualListProps-2.42.0
childrenCustomize render list(props: TransferCustomListProps) => ReactNode--
filterOptionA function to determine whether an item should show in search result list(inputValue: string, item: TransferItem) => boolean(inputValue, item) => item.value.indexOf(inputValue) !== -1-
onResetDataCallback when reset-button is clicked() => void--
onSelectChangeCallback when selected items are changed(leftSelectedKeys: string[], rightSelectedKeys: string[]) => void--
renderA function to generate the item shown on a column.(item: TransferItem) => any--

TransferCustomListProps

export interface TransferCustomListProps
  extends Pick<
    TransferListProps,
    | "disabled"
    | "listType"
    | "selectedKeys"
    | "validKeys"
    | "selectedDisabledKeys"
  > {
  filteredItems: TransferItem[];
  onItemSelect: (key: string, selected: boolean) => void;
  onItemRemove: (key: string) => void;
  onItemSelectAll: (keys: string[], selected: boolean) => void;
}

TransferItem

export type TransferItem = {
  key: string;
  value: string;
  disabled?: boolean;
};

TransferListTitle

type TransferListTitle =
  | string
  | ((params: {
      countTotal: number;
      countSelected: number;
      clear: () => void;
      checkbox: ReactNode;
      searchInput: ReactNode;
    }) => ReactNode);

AvailableVirtualListProps

export type AvailableVirtualListProps = Pick<
  VirtualListProps<any>,
  | "height"
  | "itemHeight"
  | "threshold"
  | "isStaticItemHeight"
  | "scrollOptions"
  | "onScroll"
  | "wrapperChild"
>;

Transfer.Item

PropertyDescriptionTypeDefault
keyUnique identifier of transfer itemstring (Required)-
valueValue of transfer itemstring (Required)-
disabledWhether this item is disabledboolean-