# Transfer

- Page: https://jiguang132.com/resources/ant-design/docs/transfer
- Resource: Ant Design (https://jiguang132.com/resources/ant-design.md)
- All guides: https://jiguang132.com/resources/ant-design/docs.md

Double column transfer choice box.


## When To Use

- It is a select control essentially which can be used for selecting multiple items.
- Transfer can display more information for items and take up more space.

Transfer the elements between two columns in an intuitive and efficient way.

One or more elements can be selected from either column, one click on the proper `direction` button, and the transfer is done. The left column is considered the `source` and the right column is considered the `target`. As you can see, these names are reflected in the API.

> notice: Transfer is a controlled component, uncontrolled mode is not supported.

## Examples


- Basic · `basic`
- One Way · `oneWay`
- Search · `search`
- Advanced · `advanced`
- Custom datasource · `custom-item`
- Custom Actions · `actions`
- Pagination · `large-data`
- Table Transfer · `table-transfer`
- Tree Transfer · `tree-transfer`
- Status · `status`
- Custom semantic dom styling · `style-class`



## API

Common props ref：[Common props](#jguang-common-props)

### Transfer

| Property | Description | Type | Default | Version | [Global Config](/components/config-provider#component-config) |
| --- | --- | --- | --- | --- | --- |
| actions | A set of operations that are sorted from top to bottom. When an array of strings is provided, default buttons will be used; when an array of ReactNode is provided, custom elements will be used | ReactNode\[] | \[`>`, `<`] | 6.0.0 | × |
| classNames | Customize class for each semantic structure inside the component. Supports object or function. | Record<[SemanticDOM](#semantic-dom), string> \| (info: { props })=> Record<[SemanticDOM](#semantic-dom), string> | - | 6.0.0 | 6.0.0 |
| dataSource | Used for setting the source data. The elements that are part of this array will be present the left column. Except the elements whose keys are included in `targetKeys` prop | [RecordType extends TransferItem = TransferItem](https://github.com/ant-design/ant-design/blob/1bf0bab2a7bc0a774119f501806e3e0e3a6ba283/components/transfer/index.tsx#L12)\[] | \[] |  | × |
| disabled | Whether disabled transfer | boolean | false |  | × |
| selectionsIcon | custom dropdown icon | React.ReactNode |  | 5.8.0 | 5.14.0 |
| filterOption | A function to determine whether an item should show in search result list, only works when searching, (add `direction` support since 5.9.0+) | (inputValue, option, direction: `left` \| `right`): boolean | - |  | × |
| footer | A function used for rendering the footer | (props, { direction }) => ReactNode | - | direction: 4.17.0 | × |
| ~~listStyle~~ | A custom CSS style used for rendering the transfer columns. Use `styles.section` instead | object \| ({direction: `left` \| `right`}) => object | - |  | × |
| locale | The i18n text including filter, empty text, item unit, etc | { itemUnit: string; itemsUnit: string; searchPlaceholder: string; notFoundContent: ReactNode \| ReactNode[]; } | { itemUnit: `item`, itemsUnit: `items`, notFoundContent: `No data`, searchPlaceholder: `Search here` } |  | × |
| oneWay | Display as single direction style | boolean | false | 4.3.0 | × |
| ~~operations~~ | A set of operations that are sorted from top to bottom. Use `actions` instead. | string\[] | \[`>`, `<`] |  | × |
| ~~operationStyle~~ | A custom CSS style used for rendering the operations column. Use `styles.actions` instead. | object | - |  | × |
| pagination | Use pagination. Not work in render props | boolean \| { pageSize: number, simple: boolean, showSizeChanger?: boolean, showLessItems?: boolean } | false | 4.3.0 | × |
| render | The function to generate the item shown on a column. Based on an record (element of the dataSource array), this function should return a React element which is generated from that record. Also, it can return a plain object with `value` and `label`, `label` is a React element and `value` is for title | (record) => ReactNode | - |  | × |
| selectAllLabels | A set of customized labels for select all checkboxes on the header | (ReactNode \| (info: { selectedCount: number, totalCount: number }) => ReactNode)\[] | - |  | × |
| selectedKeys | A set of keys of selected items | string\[] \| number\[] | \[] |  | × |
| showSearch | If included, a search box is shown on each column | boolean \| { placeholder:string,defaultValue:string } | false |  | × |
| showSelectAll | Show select all checkbox on the header | boolean | true |  | × |
| status | Set validation status | 'error' \| 'warning' | - | 4.19.0 | × |
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<[SemanticDOM](#semantic-dom), CSSProperties> \| (info: { props })=> Record<[SemanticDOM](#semantic-dom), CSSProperties> | - | 6.0.0 | 6.0.0 |
| targetKeys | A set of keys of elements that are listed on the right column | string\[] \| number\[] | \[] |  | × |
| titles | A set of titles that are sorted from left to right | ReactNode\[] | - |  | × |
| onChange | A callback function that is executed when the transfer between columns is complete | (targetKeys, direction, moveKeys): void | - |  | × |
| onScroll | A callback function which is executed when scroll options list | (direction, event): void | - |  | × |
| onSearch | A callback function which is executed when search field are changed | (direction: `left` \| `right`, value: string): void | - |  | × |
| onSelectChange | A callback function which is executed when selected items are changed | (sourceSelectedKeys, targetSelectedKeys): void | - |  | × |

### Render Props

Transfer accept `children` to customize render list, using follow props:

| Property | Description | Type | Version |
| --- | --- | --- | --- |
| direction | List render direction | `left` \| `right` |  |
| disabled | Disable list or not | boolean |  |
| filteredItems | Filtered items | RecordType\[] |  |
| selectedKeys | Selected items | string\[] \| number\[] |  |
| onItemSelect | Select item | (key: string \| number, selected: boolean) |  |
| onItemSelectAll | Select a group of items | (keys: string\[] \| number\[], selected: boolean) |  |

#### example

```jsx
<Transfer {...props}>{(listProps) => <YourComponent {...listProps} />}</Transfer>
```

## Warning

According to the [standard](https://react.dev/learn/rendering-lists#why-does-react-need-keys) of React, the key should always be supplied directly to the elements in the array. In Transfer, the keys should be set on the elements included in `dataSource` array. By default, `key` property is used as a unique identifier.

If there's no `key` in your data, you should use `rowKey` to specify the key that will be used to uniquely identify each element.

```jsx
// eg. your primary key is `uid`
return <Transfer rowKey={(record) => record.uid} />;
```

## Semantic DOM

| Semantic node | Native description | Version |
| --- | --- | --- |
| `root` | Root element with flex layout, transfer container base styles and layout control | — |
| `section` | Section element with flex layout, width, height, min height, border, border radius and other single-side transfer container styles | — |
| `source.section` | Source section element, only applies to left transfer section container styles | 6.4.0 |
| `target.section` | Target section element, only applies to right transfer section container styles | 6.4.0 |
| `source.header` | Source header element, only applies to left header area styles | 6.4.0 |
| `target.header` | Target header element, only applies to right header area styles | 6.4.0 |
| `source.title` | Source title element, only applies to left title text styles | 6.4.0 |
| `target.title` | Target title element, only applies to right title text styles | 6.4.0 |
| `source.body` | Source body element, only applies to left list body styles | 6.4.0 |
| `target.body` | Target body element, only applies to right list body styles | 6.4.0 |
| `source.list` | Source list element, only applies to left list content styles | 6.4.0 |
| `target.list` | Target list element, only applies to right list content styles | 6.4.0 |
| `source.item` | Source item element, only applies to left list item styles | 6.4.0 |
| `target.item` | Target item element, only applies to right list item styles | 6.4.0 |
| `source.itemIcon` | Source item icon element, only applies to left icon styles | 6.4.0 |
| `target.itemIcon` | Target item icon element, only applies to right icon styles | 6.4.0 |
| `source.itemContent` | Source item content element, only applies to left text content styles | 6.4.0 |
| `target.itemContent` | Target item content element, only applies to right text content styles | 6.4.0 |
| `source.footer` | Source footer element, only applies to left footer area styles | 6.4.0 |
| `target.footer` | Target footer element, only applies to right footer area styles | 6.4.0 |
| `header` | Header element with flex layout, alignment, height, padding, color, background color, bottom border, border radius and other header area styles | — |
| `title` | Title element with text ellipsis, flex ratio, text alignment, auto left margin and other title text layout and styles | — |
| `body` | Body element with list main area container styles and layout control | — |
| `list` | List element with list content styles, layout and scroll control | — |
| `item` | List item element with relative positioning, padding, border, hover state, selected state, disabled state and other list item interaction styles | — |
| `itemIcon` | List item icon element with checkbox and other icon styles and interaction states | — |
| `itemContent` | List item content element with text ellipsis, padding and other list item text content display styles | — |
| `footer` | Footer element with bottom operation area styles and layout | — |
| `actions` | Actions element with transfer button group styles, layout and interaction states | — |

Semantic description source: `vendor/components/transfer/demo/_semantic.tsx`

## Design Token

Types, inheritance and declarations retain the pinned native source. Defaults are computed by the native theme and may be overridden by ConfigProvider; this table does not invent static defaults.

| Token | Type | Native description |
| --- | --- | --- |
| `listWidth` | `number \| string` | Width of list |
| `listWidthLG` | `number \| string` | Width of large list |
| `listHeight` | `number \| string` | Height of list |
| `itemHeight` | `number \| string` | Height of list item |
| `itemPaddingBlock` | `number \| string` | Vertical padding of list item |
| `headerHeight` | `number \| string` | Height of header |

Declaration source: `vendor/components/transfer/style/index.ts`

```ts
import { unit } from '@ant-design/cssinjs';

import type { CSSObject } from '@ant-design/cssinjs';

import { operationUnit, resetComponent, resetIcon, textEllipsis } from '../../style';

import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';

import { genStyleHooks, mergeToken } from '../../theme/internal';

export interface ComponentToken {
  /**
   * @desc 列表宽度
   * @descEN Width of list
   */
  listWidth: number | string;
  /**
   * @desc 大号列表宽度
   * @descEN Width of large list
   */
  listWidthLG: number | string;
  /**
   * @desc 列表高度
   * @descEN Height of list
   */
  listHeight: number | string;
  /**
   * @desc 列表项高度
   * @descEN Height of list item
   */
  itemHeight: number | string;
  /**
   * @desc 列表项纵向内边距
   * @descEN Vertical padding of list item
   */
  itemPaddingBlock: number | string;
  /**
   * @desc 顶部高度
   * @descEN Height of header
   */
  headerHeight: number | string;
}

interface TransferToken extends FullToken<'Transfer'> {
  transferHeaderVerticalPadding: number;
}
```

## FAQ

### How to support fetch and present data from a remote server in Transfer column. {#faq-async-data-loading}

In order to keep the page number synchronized, you can disable columns you checked without removing the option: <https://codesandbox.io/s/objective-wing-6iqbx>


## Shared native props {#jguang-common-props}


> Tips: The following generic properties apply to most antd components; those not supported are described separately.

| Property | Description | Type | Default |
| --- | --- | --- | --- |
| style | The additional style | CSSProperties | - |
| className | The additional css class | string | - |
| rootClassName | ClassName on the root element | string | - |
| autoFocus | Auto focus when component mounted, only effective for focusable elements like forms, links, etc. | boolean | false |


## Install and reproduce an example

```bash
npm install antd@6.6.5 @ant-design/icons@6.3.4 dayjs@1.11.23
```

Use ConfigProvider and native App; configure dayjs locale separately. Each example lists its complete source files and additional pinned dependencies in View code. Example names select demos, not universal component props. See the resource setup guide for theme, locale and SSR.

## Native type references

The source viewer includes unchanged native implementations and the following source declarations. Inherited types remain in their native packages. English source comments are preserved as code reference.

- `vendor/components/transfer/Actions.tsx`
- `vendor/components/transfer/ListBody.tsx`
- `vendor/components/transfer/ListItem.tsx`
- `vendor/components/transfer/Section.tsx`
- `vendor/components/transfer/index.tsx`
- `vendor/components/transfer/interface.ts`
- `vendor/components/transfer/search.tsx`
- `vendor/components/transfer/style/index.ts`

## Source and license

https://github.com/ant-design/ant-design/tree/4a39f54842eade4e565ab336ef6097cd7e723cdd

Original bilingual prose and executable examples are retained. Website-only embeds and token tables are expanded locally. Ant Design is MIT; separately listed dependency notices also apply. Upload previews block outbound requests and do not provide a backend.

---

Index of all JGuang resources: https://jiguang132.com/llms.txt
