Input · Transfer

Transfer

A more intuitive and efficient multiple-selection selector, which can reveal more information about options, and supports search functions. The disadvantage is that it takes up more space

Demos

How to import

import { Transfer } from '@fibrous/semi-ui-react';

Basic Usage

dataSource should have value、label、key.

总个数:100
选项名称 0
选项名称 1
选项名称 2
选项名称 3
选项名称 4
选项名称 5
选项名称 6
选项名称 7
选项名称 8
选项名称 9
选项名称 10
选项名称 11
选项名称 12
选项名称 13
选项名称 14
选项名称 15
选项名称 16
选项名称 17
选项名称 18
选项名称 19
选项名称 20
选项名称 21
选项名称 22
选项名称 23
选项名称 24
选项名称 25
选项名称 26
选项名称 27
选项名称 28
选项名称 29
选项名称 30
选项名称 31
选项名称 32
选项名称 33
选项名称 34
选项名称 35
选项名称 36
选项名称 37
选项名称 38
选项名称 39
选项名称 40
选项名称 41
选项名称 42
选项名称 43
选项名称 44
选项名称 45
选项名称 46
选项名称 47
选项名称 48
选项名称 49
选项名称 50
选项名称 51
选项名称 52
选项名称 53
选项名称 54
选项名称 55
选项名称 56
选项名称 57
选项名称 58
选项名称 59
选项名称 60
选项名称 61
选项名称 62
选项名称 63
选项名称 64
选项名称 65
选项名称 66
选项名称 67
选项名称 68
选项名称 69
选项名称 70
选项名称 71
选项名称 72
选项名称 73
选项名称 74
选项名称 75
选项名称 76
选项名称 77
选项名称 78
选项名称 79
选项名称 80
选项名称 81
选项名称 82
选项名称 83
选项名称 84
选项名称 85
选项名称 86
选项名称 87
选项名称 88
选项名称 89
选项名称 90
选项名称 91
选项名称 92
选项名称 93
选项名称 94
选项名称 95
选项名称 96
选项名称 97
选项名称 98
选项名称 99
已选个数:0
暂无内容,可从左侧勾选
Code
import { Transfer } from '@fibrous/semi-ui-react';

export default function TransferDemo() {
    const data = Array.from({ length: 100 }, (_v, i) => {
        return {
            label: `选项名称 ${i}`,
            value: i,
            disabled: false,
            key: `key-${i}`,
        };
    });
    return <Transfer style={{ width: 568, height: 416 }} dataSource={data} onChange={(values, items) => console.log(values, items)} />;
}

Grouped

Set type to groupList

For grouped dataSource, the first-level child elements must have title and children attributes, structure reference <GroupItem>

Does not support multi-level nesting

总个数:13
类别A
A-1
A-2
A-3
类别B
B-1
B-2
B-3(disabled)
类别C
C-1
C-2
C-3
C-4
C-5
C-6
C-7
已选个数:1
B-3(disabled)
Code
import { Transfer } from '@fibrous/semi-ui-react';

export default function TransferDemo() {
    const dataWithGroup = [
        {
            title: '类别A',
            children: [
                { label: 'A-1', value: 1, disabled: false, key: 1 },
                { label: 'A-2', value: 2, disabled: false, key: 2 },
                { label: 'A-3', value: 3, disabled: false, key: 3 },
            ],
        },
        {
            title: '类别B',
            children: [
                { label: 'B-1', value: 4, disabled: false, key: 4 },
                { label: 'B-2', value: 5, disabled: false, key: 5 },
                { label: 'B-3(disabled)', value: 6, disabled: true, key: 6 },
            ],
        },
        {
            title: '类别C',
            children: [
                { label: 'C-1', value: 7, disabled: false, key: 7 },
                { label: 'C-2', value: 8, disabled: false, key: 8 },
                { label: 'C-3', value: 9, disabled: false, key: 9 },
                { label: 'C-4', value: 10, disabled: false, key: 10 },
                { label: 'C-5', value: 11, disabled: false, key: 11 },
                { label: 'C-6', value: 12, disabled: false, key: 12 },
                { label: 'C-7', value: 13, disabled: false, key: 13 },
            ],
        },
    ];
    return <Transfer type="groupList" defaultValue={[6]} style={{ width: 568 }} dataSource={dataWithGroup} onChange={(values, items) => console.log(values, items)} />;
}

Custom filtering logic, custom option data rendering

Use filter to customize the search logic. When it returns true, it means that the current item meets the filter rules and keeps the display of the current item in the list. If it returns false, it means it does not match, and the current item will be hidden.
When type is treeList, if you need to customize search logic, you need to set filter to true and set a custom search function through filterTreeNode of treeProps.

Using renderSourceItem, you can customize the rendering structure of each source data on the left.
Using renderSelectedItem you can customize the rendering structure of each selected item on the right.

总个数:6
夏
夏可漫
申
申悦
文
文嘉茂
曲
曲晨一
二
曲晨二
三
曲晨三
已选个数:2
夏
夏可漫
申
申悦
Code
import { useState } from 'react';
import { IconClose } from '@fibrous/semi-icons-react';
import { Transfer, Button, Checkbox, Avatar, Highlight, type TransferDataItem, type TransferRenderSelectedItemProps, type TransferRenderSourceItemProps } from '@fibrous/semi-ui-react';

export default function TransferDemo() {
    const [searchText, setSearchText] = useState('');
    const renderSourceItem = (item: TransferRenderSourceItemProps) => {
        return (
            <div className="components-transfer-demo-source-item" key={item.key}>
                <Checkbox
                    onChange={() => {
                        item.onChange?.();
                    }}
                    checked={item.checked}
                    style={{ height: 52, alignItems: 'center' }}
                >
                    <Avatar color={item.color} size="small">
                        {item.abbr}
                    </Avatar>
                    <div className="info">
                        <div className="name">
                            <Highlight sourceString={String(item.label)} searchWords={[searchText]} />
                        </div>
                        <div className="email">
                            <Highlight sourceString={String(item.value)} searchWords={[searchText]} />
                        </div>
                    </div>
                </Checkbox>
            </div>
        );
    };

    const renderSelectedItem = (item: TransferRenderSelectedItemProps) => {
        return (
            <div className="components-transfer-demo-selected-item" key={item.key}>
                <Avatar color={item.color} size="small">
                    {item.abbr}
                </Avatar>
                <div className="info">
                    <div className="name">{item.label}</div>
                    <div className="email">{item.value}</div>
                </div>
                <Button className="remove" theme="borderless" type="tertiary" size="small" icon={<IconClose />} aria-label={`移除 ${item.label}`} onClick={item.onRemove} />
            </div>
        );
    };

    const customFilter = (searchValue: string, item: TransferDataItem) => {
        return String(item.value).includes(searchValue) || String(item.label).includes(searchValue);
    };

    const data = [
        { label: '夏可漫', value: 'xiakeman@example.com', abbr: '夏', color: 'amber', area: 'US', key: 1 },
        { label: '申悦', value: 'shenyue@example.com', abbr: '申', color: 'indigo', area: 'UK', key: 2 },
        { label: '文嘉茂', value: 'wenjiamao@example.com', abbr: '文', color: 'cyan', area: 'HK', key: 3 },
        { label: '曲晨一', value: 'quchenyi@example.com', abbr: '曲', color: 'blue', area: 'India', key: 4 },
        { label: '曲晨二', value: 'quchener@example.com', abbr: '二', color: 'blue', area: 'India', key: 5 },
        { label: '曲晨三', value: 'quchensan@example.com', abbr: '三', color: 'blue', area: 'India', key: 6 },
    ];

    return (
        <Transfer
            style={{ width: 568 }}
            dataSource={data}
            filter={customFilter}
            defaultValue={['xiakeman@example.com', 'shenyue@example.com']}
            renderSelectedItem={renderSelectedItem}
            renderSourceItem={renderSourceItem}
            inputProps={{ placeholder: '搜索姓名或邮箱' }}
            onSearch={(searchText) => setSearchText(searchText)}
            onChange={(values, items) => console.log(values, items)}
        />
    );
}
.components-transfer-demo-selected-item {
    .remove {
        opacity: 0;
    }
    &:hover,
    &:focus-within {
        .remove {
            opacity: 1;
        }
    }
}

.components-transfer-demo-selected-item,
.components-transfer-demo-source-item {
    height: 52px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    &:hover {
        background-color: var(--semi-color-fill-0);
    }
    .info {
        margin-left: 8px;
        flex-grow: 1;
    }
    .name {
        font-size: 14px;
        line-height: 20px;
    }
    .email {
        font-size: 12px;
        line-height: 16px;
        color: var(--semi-color-text-2);
    }
}

Disabled

总个数:20
选项名称 0
选项名称 1
选项名称 2
选项名称 3
选项名称 4
选项名称 5
选项名称 6
选项名称 7
选项名称 8
选项名称 9
选项名称 10
选项名称 11
选项名称 12
选项名称 13
选项名称 14
选项名称 15
选项名称 16
选项名称 17
选项名称 18
选项名称 19
已选个数:2
选项名称 2
选项名称 4
Code
import { Transfer } from '@fibrous/semi-ui-react';
export default function TransferDemo() {
    const data = Array.from({ length: 20 }, (_v, i) => {
        return {
            label: `选项名称 ${i}`,
            value: i,
            disabled: false,
            key: `key-${i}`,
        };
    });
    return <Transfer style={{ width: 568, height: 416 }} disabled dataSource={data} defaultValue={[2, 4]} onChange={(values, items) => console.log(values, items)} />;
}

Drag and drop sort

Set draggable to true to enable the drag sort function.

总个数:30
选项名称 0
选项名称 1
选项名称 2
选项名称 3
选项名称 4
选项名称 5
选项名称 6
选项名称 7
选项名称 8
选项名称 9
选项名称 10
选项名称 11
选项名称 12
选项名称 13
选项名称 14
选项名称 15
选项名称 16
选项名称 17
选项名称 18
选项名称 19
选项名称 20
选项名称 21
选项名称 22
选项名称 23
选项名称 24
选项名称 25
选项名称 26
选项名称 27
选项名称 28
选项名称 29
已选个数:2
选项名称 2
选项名称 4
Code
import { Transfer } from '@fibrous/semi-ui-react';
export default function TransferDemo() {
    const data = Array.from({ length: 30 }, (_v, i) => {
        return {
            label: `选项名称 ${i}`,
            value: i,
            disabled: false,
            key: `key-${i}`,
        };
    });
    return <Transfer style={{ width: 568, height: 416 }} dataSource={data} defaultValue={[2, 4]} draggable onChange={(values, items) => console.log(values, items)} />;
}

Left panel pagination

When there are many options on the left, you can enable pagination through the pagination prop.

pagination accepts an object with the following properties:

  • pageSize: Number of items per page, default is 10
  • currentPage: Current page number (controlled mode)
  • defaultCurrentPage: Default current page number (uncontrolled mode)
  • onPageChange: Callback when page changes
总个数:100
选项名称 0
选项名称 1
选项名称 2
选项名称 3
选项名称 4
选项名称 5
选项名称 6
选项名称 7
选项名称 8
选项名称 9
已选个数:0
暂无内容,可从左侧勾选
Code
import { Transfer } from '@fibrous/semi-ui-react';

export default function TransferDemo() {
    const data = Array.from({ length: 100 }, (_v, i) => {
        return {
            label: `选项名称 ${i}`,
            value: i,
            disabled: false,
            key: `key-${i}`,
        };
    });
    return (
        <Transfer
            style={{ width: 568, height: 416 }}
            dataSource={data}
            pagination={{
                pageSize: 10,
            }}
            onChange={(values, items) => console.log(values, items)}
        />
    );
}

Left panel pagination + controlled page

You can control the current page number through pagination.currentPage.

当前页码: 1
总个数:100
选项名称 0
选项名称 1
选项名称 2
选项名称 3
选项名称 4
选项名称 5
选项名称 6
选项名称 7
选项名称 8
选项名称 9
已选个数:0
暂无内容,可从左侧勾选
Code
import { useState } from 'react';
import { Transfer, ButtonGroup, Button } from '@fibrous/semi-ui-react';

export default function TransferDemo() {
    const [currentPage, setCurrentPage] = useState(1);
    const data = Array.from({ length: 100 }, (_v, i) => {
        return {
            label: `选项名称 ${i}`,
            value: i,
            disabled: false,
            key: `key-${i}`,
        };
    });
    return (
        <div>
            <ButtonGroup style={{ marginBottom: 12 }}>
                <Button onClick={() => setCurrentPage(1)}>第1页</Button>
                <Button onClick={() => setCurrentPage(2)}>第2页</Button>
                <Button onClick={() => setCurrentPage(5)}>第5页</Button>
                <Button onClick={() => setCurrentPage(10)}>第10页</Button>
            </ButtonGroup>
            <div>当前页码: {currentPage}</div>
            <Transfer
                style={{ width: 568, height: 416 }}
                dataSource={data}
                pagination={{
                    pageSize: 10,
                    currentPage,
                    onPageChange: (page) => setCurrentPage(page),
                }}
                onChange={(values, items) => console.log(values, items)}
            />
        </div>
    );
}

Drag and drop + custom selected rendering

Set draggable to true to enable the drag and drop sorting function; use renderSelectedItem to customize the rendering of the selected items on the right; You can define the trigger as any ReactNode you want and add styles. Drag the trigger and use sortableHandle to wrap it

总个数:6
夏
夏可漫
申
申悦
文
文嘉茂
曲
曲晨一
二
曲晨二
三
曲晨三
已选个数:2
夏
夏可漫
申
申悦
Code
import { IconHandle, IconClose } from '@fibrous/semi-icons-react';
import { Transfer, Button, Checkbox, Avatar, type TransferDataItem, type TransferRenderSelectedItemProps, type TransferRenderSourceItemProps } from '@fibrous/semi-ui-react';

export default function TransferDemo() {
    const renderSourceItem = (item: TransferRenderSourceItemProps) => {
        return (
            <div className="components-transfer-demo-source-item" key={item.key}>
                <Checkbox
                    onChange={() => {
                        item.onChange?.();
                    }}
                    checked={item.checked}
                    style={{ height: 52, alignItems: 'center' }}
                >
                    <Avatar color={item.color} size="small">
                        {item.abbr}
                    </Avatar>
                    <div className="info">
                        <div className="name">{item.label}</div>
                        <div className="email">{item.value}</div>
                    </div>
                </Checkbox>
            </div>
        );
    };

    const renderSelectedItem = (item: TransferRenderSelectedItemProps) => {
        const { sortableHandle } = item;
        if (!sortableHandle) {
            return null;
        }
        const DragHandle = sortableHandle(() => <IconHandle className="semi-right-item-drag-handler" />);
        return (
            <div className="components-transfer-demo-selected-item" key={item.key}>
                <DragHandle />
                <Avatar color={item.color} size="small">
                    {item.abbr}
                </Avatar>
                <div className="info">
                    <div className="name">{item.label}</div>
                    <div className="email">{item.value}</div>
                </div>
                <Button className="remove" theme="borderless" type="tertiary" size="small" icon={<IconClose />} aria-label={`移除 ${item.label}`} onClick={item.onRemove} />
            </div>
        );
    };

    const customFilter = (searchValue: string, item: TransferDataItem) => {
        return String(item.value).includes(searchValue) || String(item.label).includes(searchValue);
    };

    const data = [
        { label: '夏可漫', value: 'xiakeman@example.com', abbr: '夏', color: 'amber', area: 'US', key: 1 },
        { label: '申悦', value: 'shenyue@example.com', abbr: '申', color: 'indigo', area: 'UK', key: 2 },
        { label: '文嘉茂', value: 'wenjiamao@example.com', abbr: '文', color: 'cyan', area: 'HK', key: 3 },
        { label: '曲晨一', value: 'quchenyi@example.com', abbr: '曲', color: 'blue', area: 'India', key: 4 },
        { label: '曲晨二', value: 'quchener@example.com', abbr: '二', color: 'blue', area: 'India', key: 5 },
        { label: '曲晨三', value: 'quchensan@example.com', abbr: '三', color: 'blue', area: 'India', key: 6 },
    ];

    return (
        <Transfer
            draggable
            style={{ width: 568 }}
            dataSource={data}
            filter={customFilter}
            defaultValue={['xiakeman@example.com', 'shenyue@example.com']}
            renderSelectedItem={renderSelectedItem}
            renderSourceItem={renderSourceItem}
            inputProps={{ placeholder: '搜索姓名或邮箱' }}
            onChange={(values, items) => console.log(values, items)}
        />
    );
}

Custom rendering header information in panel

Semi has provided renderSourceHeader and renderSelectedHeader parameter allows users to customize the header information of the left and right panels.
renderSourceHeader: (props: SourceHeaderProps) => ReactNode
renderSelectedHeader: (props: SelectedHeaderProps) => ReactNode
The parameter types are as follows:

type SourceHeaderProps = {
    num: number; // The total number of data or the number of filtered results
    showButton: boolean; // Whether to show select all/unselect all buttons
    allChecked: boolean; // Whether the current data has been selected
    onAllClick: () => void; // Function that should be called after clicking the select/unselect all button
    leafOnlyNum?: number; // Only valid when type is treeList, represents the number of leaf nodes
};

type SelectedHeaderProps = {
    num: number; // The total number of selected data
    showButton: boolean; // Whether to show the clear button
    onClear: () => void; // Function that should be called after clicking the clear button
};

The example is as follows:

共 30 项
选项名称 0
选项名称 1
选项名称 2
选项名称 3
选项名称 4
选项名称 5
选项名称 6
选项名称 7
选项名称 8
选项名称 9
选项名称 10
选项名称 11
选项名称 12
选项名称 13
选项名称 14
选项名称 15
选项名称 16
选项名称 17
选项名称 18
选项名称 19
选项名称 20
选项名称 21
选项名称 22
选项名称 23
选项名称 24
选项名称 25
选项名称 26
选项名称 27
选项名称 28
选项名称 29
0 项已选
暂无内容,可从左侧勾选
Code
import { Transfer, Button, type TransferProps } from '@fibrous/semi-ui-react';

export default function TransferDemo() {
    const data = Array.from({ length: 30 }, (_v, i) => {
        return {
            label: `选项名称 ${i}`,
            value: i,
            disabled: false,
            key: `key-${i}`,
        };
    });

    const renderSourceHeader: TransferProps['renderSourceHeader'] = ({ num, showButton, allChecked, onAllClick }) => {
        return (
            <div style={{ margin: '10px 0 0 10px', height: 24, display: 'flex', alignItems: 'center' }}>
                <span>共 {num} 项</span>
                {showButton && (
                    <Button theme="borderless" type="tertiary" size="small" onClick={onAllClick}>
                        {allChecked ? '取消全选' : '全选'}
                    </Button>
                )}
            </div>
        );
    };

    const renderSelectedHeader: TransferProps['renderSelectedHeader'] = ({ num, showButton, onClear }) => {
        return (
            <div style={{ margin: '10px 0 0 10px', height: 24, display: 'flex', alignItems: 'center' }}>
                <span>{num} 项已选</span>
                {showButton && (
                    <Button theme="borderless" type="tertiary" size="small" onClick={onClear}>
                        清空
                    </Button>
                )}
            </div>
        );
    };

    return <Transfer style={{ width: 568, height: 416 }} dataSource={data} renderSourceHeader={renderSourceHeader} renderSelectedHeader={renderSelectedHeader} />;
}

Fully custom rendering

Semi provides renderSourcePanel and renderSelectedPanel input parameters, allowing you to completely customize the rendering structure of the left and right panels. With this function, you can directly reuse the logic capabilities inside the Transfer to implement the Transfer component with a highly customized style structure renderSourcePanel: (sourcePanelProps: SourcePanelProps) => ReactNode SourcePanelProps contains the following parameters, from which you can get data to render your Panel structure

interface SourcePanelProps {
    value: Array<string | number>; // value of all selected items
    loading?: boolean; // Whether loading
    noMatch: boolean; // Whether there is no matching item that matches the current search value
    filterData: Array<Item>; // items that match the current search value
    sourceData: Array<Item>; // All items
    propsDataSource: Array<Item> | Array<GroupItem> | Array<TreeItem>; // The dataSource of Transfer
    allChecked: boolean; // Whether to select all
    showNumber: number; // Filter the number of results
    inputValue: string; // the value of the input search box
    onSearch: (searchString: string) => void; // The function that should be called when the search box changes, the input parameter is the search value
    onAllClick: () => void; // The function that should be called when all the buttons on the left are clicked
    onSelectOrRemove: (item: Item) => void; // The function that should be called when selecting or deleting a single option, the input should be the current operation item
    onSelect: (value: Array<string | number>) => void; // controlled batch selection, the input is the values of the selected items
    selectedItems: Map<string | number, Item>; // collection of all selected items, the key of the Map is item.key
}

renderSelectedPanel: (selectedPanelProps: SelectedPanelProps) => ReactNode SelectedPanelProps contains the following parameters

interface SelectedPanelProps {
    length: number; // number of selected options
    onClear: () => void; // The callback function that should be called when clicking to clear
    onRemove: (item: Item) => void; // The function that should be called when deleting a single option
    onSortEnd: ({ oldIndex, newIndex }) => void; // The function that should be called when reordering the results
    selectedData: Array<Item>; // All selected items collection
}
门店列表
待选门店: 100

海底捞门店 0

海底捞门店 1

海底捞门店 2

海底捞门店 3

海底捞门店 4

海底捞门店 5

海底捞门店 6

海底捞门店 7

海底捞门店 8

海底捞门店 9

海底捞门店 10

海底捞门店 11

海底捞门店 12

海底捞门店 13

海底捞门店 14

海底捞门店 15

海底捞门店 16

海底捞门店 17

海底捞门店 18

海底捞门店 19

海底捞门店 20

海底捞门店 21

海底捞门店 22

海底捞门店 23

海底捞门店 24

海底捞门店 25

海底捞门店 26

海底捞门店 27

海底捞门店 28

海底捞门店 29

海底捞门店 30

海底捞门店 31

海底捞门店 32

海底捞门店 33

海底捞门店 34

海底捞门店 35

海底捞门店 36

海底捞门店 37

海底捞门店 38

海底捞门店 39

海底捞门店 40

海底捞门店 41

海底捞门店 42

海底捞门店 43

海底捞门店 44

海底捞门店 45

海底捞门店 46

海底捞门店 47

海底捞门店 48

海底捞门店 49

海底捞门店 50

海底捞门店 51

海底捞门店 52

海底捞门店 53

海底捞门店 54

海底捞门店 55

海底捞门店 56

海底捞门店 57

海底捞门店 58

海底捞门店 59

海底捞门店 60

海底捞门店 61

海底捞门店 62

海底捞门店 63

海底捞门店 64

海底捞门店 65

海底捞门店 66

海底捞门店 67

海底捞门店 68

海底捞门店 69

海底捞门店 70

海底捞门店 71

海底捞门店 72

海底捞门店 73

海底捞门店 74

海底捞门店 75

海底捞门店 76

海底捞门店 77

海底捞门店 78

海底捞门店 79

海底捞门店 80

海底捞门店 81

海底捞门店 82

海底捞门店 83

海底捞门店 84

海底捞门店 85

海底捞门店 86

海底捞门店 87

海底捞门店 88

海底捞门店 89

海底捞门店 90

海底捞门店 91

海底捞门店 92

海底捞门店 93

海底捞门店 94

海底捞门店 95

海底捞门店 96

海底捞门店 97

海底捞门店 98

海底捞门店 99

已选同步门店: 0
暂无数据,请从左侧筛选
Code
import { type ReactNode } from 'react';
import { IconSearch } from '@fibrous/semi-icons-react';
import { Transfer, Input, Spin, Button, type TransferDataItem, type TransferSelectedPanelProps as SelectedPanelProps, type TransferSourcePanelProps as SourcePanelProps } from '@fibrous/semi-ui-react';

const dataSource = Array.from({ length: 100 }, (_v, i) => ({
    label: `海底捞门店 ${i}`,
    value: i,
    disabled: false,
    key: `key-${i}`,
}));

function renderItem(type: 'source' | 'selected', item: TransferDataItem, onItemAction: (item: TransferDataItem) => void, selectedItems?: SourcePanelProps['selectedItems']) {
    let buttonText = '删除';
    if (type === 'source') {
        buttonText = selectedItems?.has(item.key) ? '删除' : '添加';
    }
    return (
        <div className="semi-transfer-item panel-item" key={item.key}>
            <p>{item.label}</p>
            <Button theme="borderless" type="primary" onClick={() => onItemAction(item)} className="panel-item-remove" size="small">
                {buttonText}
            </Button>
        </div>
    );
}

function renderSourcePanel({ loading, noMatch, filterData, selectedItems, allChecked, onAllClick, inputValue, onSearch, onSelectOrRemove }: SourcePanelProps) {
    let content: ReactNode;
    if (loading) {
        content = <Spin />;
    } else if (noMatch) {
        content = <div className="empty sp-font">{inputValue ? '无搜索结果' : '暂无内容'}</div>;
    } else {
        content = filterData.map((item) => renderItem('source', item, onSelectOrRemove, selectedItems));
    }
    return (
        <section className="source-panel">
            <div className="panel-header sp-font">门店列表</div>
            <div className="panel-main">
                <Input aria-label="搜索门店" style={{ width: 454, margin: '12px 14px' }} prefix={<IconSearch />} onChange={onSearch} showClear />
                <div className="panel-controls sp-font">
                    <span>待选门店: {filterData.length}</span>
                    <Button onClick={onAllClick} theme="borderless" size="small">
                        {allChecked ? '取消全选' : '全选'}
                    </Button>
                </div>
                <div className="panel-list">{content}</div>
            </div>
        </section>
    );
}

function renderSelectedPanel({ selectedData, onClear, onRemove }: SelectedPanelProps) {
    let mainContent: ReactNode = selectedData.map((item) => renderItem('selected', item, onRemove));

    if (!selectedData.length) {
        mainContent = <div className="empty sp-font">暂无数据,请从左侧筛选</div>;
    }

    return (
        <section className="selected-panel">
            <div className="panel-header sp-font">
                <div>已选同步门店: {selectedData.length}</div>
                <Button theme="borderless" type="primary" onClick={onClear} size="small">
                    清空
                </Button>
            </div>
            <div className="panel-main">{mainContent}</div>
        </section>
    );
}

export default function TransferDemo() {
    return <Transfer onChange={(values) => console.log(values)} className="component-transfer-demo-custom-panel" renderSourcePanel={renderSourcePanel} renderSelectedPanel={renderSelectedPanel} dataSource={dataSource} />;
}
.component-transfer-demo-custom-panel {
    .sp-font {
        color: var(--semi-grey-9);
        font-size: 12px;
        font-weight: 500;
        line-height: 20px;
    }

    .empty {
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .panel-item {
        flex-shrink: 0;
        height: 56px;
        border-radius: 4px;
        padding: 8px 12px;
        flex-wrap: wrap;
        background-color: rgba(22, 24, 35, 0.03);

        &-main {
            flex-grow: 1;
        }

        p {
            margin: 0 12px;
            flex-basis: 100%;
        }

        .panel-item-remove {
            cursor: pointer;
            color: var(--semi-color-primary);
        }
    }

    .panel-header {
        padding: 10px 12px;
        border: 1px solid rgba(22, 24, 35, 0.16);
        border-radius: 4px 4px 0 0;
        height: 38px;
        box-sizing: border-box;
        background-color: var(--semi-color-tertiary-light-default);
        display: flex;
        align-items: center;
        justify-content: space-between;

        .clear {
            cursor: pointer;
            color: var(--semi-color-primary);
        }
    }

    .source-panel {
        display: flex;
        flex-direction: column;
        width: 482px;
        height: 353px;

        .panel-main {
            border: 1px solid var(--semi-color-border);
            border-top: none;

            .panel-list {
                display: flex;
                flex-wrap: wrap;
                row-gap: 8px;
                column-gap: 8px;
                overflow-y: auto;
                height: 214px;
                margin-left: 12px;
                margin-right: 12px;
                padding-bottom: 8px;
            }
        }

        .panel-controls {
            margin: 10px 12px;
            font-size: 12px;
            line-height: 20px;

            .semi-button {
                margin-left: 8px;
                font-size: 12px;
            }
        }

        .panel-item {
            width: 176px;
        }

        margin-right: 16px;
    }

    .selected-panel {
        width: 200px;
        height: 353px;

        .panel-main {
            display: flex;
            flex-direction: column;
            overflow-y: auto;
            padding: 12px;
            border: 1px solid var(--semi-color-border);
            border-top: none;
            height: 323px;
            box-sizing: border-box;
            row-gap: 8px;
        }
    }
}

Fully custom rendering, drag and drop sorting

In a completely custom rendering scene, since the rendering of the drag area has also been completely taken over by you, you do not need to declare draggable. But you need to implement the drag and drop logic yourself, You can use the drag-and-drop tool library dnd-kit to quickly realize the function.

Besides, To support drag sorting, you need to call onSortEnd with oldIndex and newIndex as the input parameters after the drag sorting is over

Example using dnd-kit,The core dependency that needs to be used is @dnd-kit/react. DragDropProvider provides the drag and drop context, and the core hook is useSortable exported from @dnd-kit/react/sortable. The usage instructions of useSortable are as follows

1. Function: Obtain the necessary information during the drag and drop process through the unique id and the current index
2. Core input parameters:
    - id: unique identifier, which can be a number or a string
    - index: the current position of the item in the list
    - handle: optional, the drag handle element; the whole node is draggable when omitted
3. Core return value description:
    - ref: Associate the dom node to make it a draggable item
    - handleRef: Associate the dom node of the drag handle
    - isDragging: whether the node is being dragged

After dragging ends, in the onDragEnd of DragDropProvider, use initialIndex and index of event.operation.source to get the positions before and after the drag; event.canceled being true means the drag was canceled.

门店列表
待选门店: 100

海底捞门店 0

海底捞门店 1

海底捞门店 2

海底捞门店 3

海底捞门店 4

海底捞门店 5

海底捞门店 6

海底捞门店 7

海底捞门店 8

海底捞门店 9

海底捞门店 10

海底捞门店 11

海底捞门店 12

海底捞门店 13

海底捞门店 14

海底捞门店 15

海底捞门店 16

海底捞门店 17

海底捞门店 18

海底捞门店 19

海底捞门店 20

海底捞门店 21

海底捞门店 22

海底捞门店 23

海底捞门店 24

海底捞门店 25

海底捞门店 26

海底捞门店 27

海底捞门店 28

海底捞门店 29

海底捞门店 30

海底捞门店 31

海底捞门店 32

海底捞门店 33

海底捞门店 34

海底捞门店 35

海底捞门店 36

海底捞门店 37

海底捞门店 38

海底捞门店 39

海底捞门店 40

海底捞门店 41

海底捞门店 42

海底捞门店 43

海底捞门店 44

海底捞门店 45

海底捞门店 46

海底捞门店 47

海底捞门店 48

海底捞门店 49

海底捞门店 50

海底捞门店 51

海底捞门店 52

海底捞门店 53

海底捞门店 54

海底捞门店 55

海底捞门店 56

海底捞门店 57

海底捞门店 58

海底捞门店 59

海底捞门店 60

海底捞门店 61

海底捞门店 62

海底捞门店 63

海底捞门店 64

海底捞门店 65

海底捞门店 66

海底捞门店 67

海底捞门店 68

海底捞门店 69

海底捞门店 70

海底捞门店 71

海底捞门店 72

海底捞门店 73

海底捞门店 74

海底捞门店 75

海底捞门店 76

海底捞门店 77

海底捞门店 78

海底捞门店 79

海底捞门店 80

海底捞门店 81

海底捞门店 82

海底捞门店 83

海底捞门店 84

海底捞门店 85

海底捞门店 86

海底捞门店 87

海底捞门店 88

海底捞门店 89

海底捞门店 90

海底捞门店 91

海底捞门店 92

海底捞门店 93

海底捞门店 94

海底捞门店 95

海底捞门店 96

海底捞门店 97

海底捞门店 98

海底捞门店 99

已选同步门店: 2

海底捞门店 2

海底捞门店 4

Code
import type { ReactNode } from 'react';
import { DragDropProvider, type DragEndEvent } from '@dnd-kit/react';
import { isSortable, useSortable } from '@dnd-kit/react/sortable';
import { IconSearch, IconHandle } from '@fibrous/semi-icons-react';
import { Transfer, Input, Spin, Button, type TransferDataItem, type TransferOnSortEnd as OnSortEnd, type TransferSelectedPanelProps as SelectedPanelProps, type TransferSourcePanelProps as SourcePanelProps } from '@fibrous/semi-ui-react';

type HandleRef = (element: Element | null) => void;
type RenderSortableItem = (props: { id: string | number; handleRef: HandleRef }) => ReactNode;

interface SortableListProps {
    items: Array<string | number>;
    onSortEnd: OnSortEnd;
    renderItem: RenderSortableItem;
}

function SortableList({ items, onSortEnd, renderItem }: SortableListProps) {
    const onDragEnd = (event: DragEndEvent) => {
        const { source } = event.operation;
        if (!event.canceled && isSortable(source) && source.initialIndex !== source.index) {
            onSortEnd({ oldIndex: source.initialIndex, newIndex: source.index });
        }
    };

    return (
        <DragDropProvider onDragEnd={onDragEnd}>
            <div style={{ overflow: 'auto', display: 'flex', flexDirection: 'column', rowGap: '8px' }}>
                {items.map((value, index) => (
                    <SortableItem key={value} id={value} index={index} renderItem={renderItem} />
                ))}
            </div>
        </DragDropProvider>
    );
}

interface SortableItemProps {
    id: string | number;
    index: number;
    renderItem: RenderSortableItem;
}

function SortableItem({ id, index, renderItem }: SortableItemProps) {
    // Only the handle drags; the Accessibility plugin gives it a button role and Tab stop for keyboard sorting
    const { ref, handleRef } = useSortable({ id, index });

    return <div ref={ref}>{renderItem({ id, handleRef })}</div>;
}

const dataSource = Array.from({ length: 100 }, (_v, i) => ({
    label: `海底捞门店 ${i}`,
    value: i,
    disabled: false,
    key: `key-${i}`,
}));

function renderItem(type: 'source' | 'selected', item: TransferDataItem, onItemAction: (item: TransferDataItem) => void, selectedItems?: SourcePanelProps['selectedItems'], handleRef?: HandleRef) {
    let buttonText = '删除';

    if (type === 'source') {
        let checked = selectedItems?.has(item.key);
        buttonText = checked ? '删除' : '添加';
    }

    return (
        <div className="semi-transfer-item panel-item" key={item.key}>
            {handleRef && (
                <span ref={handleRef} aria-label={String(item.label)} style={{ lineHeight: 0 }}>
                    <IconHandle className="pane-item-drag-handler" />
                </span>
            )}
            <div className="panel-item-main" style={{ flexGrow: 1 }}>
                <p style={{ margin: '0 12px' }}>{item.label}</p>
                <Button theme="borderless" type="primary" onClick={() => onItemAction(item)} className="panel-item-remove" size="small">
                    {buttonText}
                </Button>
            </div>
        </div>
    );
}

function renderSourcePanel({ loading, noMatch, filterData, selectedItems, allChecked, onAllClick, inputValue, onSearch, onSelectOrRemove }: SourcePanelProps) {
    let content: ReactNode;
    if (loading) {
        content = <Spin />;
    } else if (noMatch) {
        content = <div className="empty sp-font">{inputValue ? '无搜索结果' : '暂无内容'}</div>;
    } else {
        content = filterData.map((item) => renderItem('source', item, onSelectOrRemove, selectedItems));
    }
    return (
        <section className="source-panel">
            <div className="panel-header sp-font">门店列表</div>
            <div className="panel-main">
                <Input aria-label="搜索门店" style={{ width: 454, margin: '12px 14px' }} prefix={<IconSearch />} onChange={onSearch} showClear />
                <div className="panel-controls sp-font">
                    <span>待选门店: {filterData.length}</span>
                    <Button onClick={onAllClick} theme="borderless" size="small">
                        {allChecked ? '取消全选' : '全选'}
                    </Button>
                </div>
                <div className="panel-list">{content}</div>
            </div>
        </section>
    );
}

function renderSelectedPanel({ selectedData, onClear, onRemove, onSortEnd }: SelectedPanelProps) {
    const renderSelectItem: RenderSortableItem = ({ id, handleRef }) => {
        const item = selectedData.find((item) => id === item.key);
        return item ? renderItem('selected', item, onRemove, undefined, handleRef) : null;
    };

    const sortData = selectedData.map((item) => item.key);

    const mainContent = (
        <div className="panel-main" style={{ display: 'block' }}>
            <SortableList onSortEnd={onSortEnd} items={sortData} renderItem={renderSelectItem} />
        </div>
    );

    return (
        <section className="selected-panel">
            <div className="panel-header sp-font">
                <div>已选同步门店: {selectedData.length}</div>
                <Button theme="borderless" type="primary" onClick={onClear} size="small">
                    清空
                </Button>
            </div>
            {mainContent}
        </section>
    );
}

export default function TransferDemo() {
    return <Transfer defaultValue={[2, 4]} onChange={(values) => console.log(values)} className="component-transfer-demo-custom-panel" renderSourcePanel={renderSourcePanel} renderSelectedPanel={renderSelectedPanel} dataSource={dataSource} />;
}

Tree Transfer

The input type is treeList, and the Tree component is used as a custom rendering list.

The properties of the default tree can be overridden by treeProps(TreeProps). The default properties of the tree on the left are

{
    multiple:true,
    disableStrictly:true,
    leafOnly:true,
    filterTreeNode:true,
    defaultExpandAll:true,
    searchRender:false,
}
总个数:12
  • Asia
  • China
  • Beijing
  • Shanghai
  • Chengdu
  • Japan
  • Osaka
  • North America
  • United States
  • Canada
  • Mexico
  • Cuba
  • 已选个数:1
    Shanghai
    Code
    import { useState } from 'react';
    import { Transfer } from '@fibrous/semi-ui-react';
    
    export default function TransferDemo() {
        const treeData = [
            {
                label: 'Asia',
                value: 'Asia',
                key: '0',
                children: [
                    {
                        label: 'China',
                        value: 'China',
                        key: '0-0',
                        children: [
                            {
                                label: 'Beijing',
                                value: 'Beijing',
                                key: '0-0-0',
                            },
                            {
                                label: 'Shanghai',
                                value: 'Shanghai',
                                key: '0-0-1',
                            },
                            {
                                label: 'Chengdu',
                                value: 'Chengdu',
                                key: '0-0-2',
                            },
                        ],
                    },
                    {
                        label: 'Japan',
                        value: 'Japan',
                        key: '0-1',
                        children: [
                            {
                                label: 'Osaka',
                                value: 'Osaka',
                                key: '0-1-0',
                            },
                        ],
                    },
                ],
            },
            {
                label: 'North America',
                value: 'North America',
                key: '1',
                children: [
                    {
                        label: 'United States',
                        value: 'United States',
                        key: '1-0',
                    },
                    {
                        label: 'Canada',
                        value: 'Canada',
                        key: '1-1',
                    },
                    {
                        label: 'Mexico',
                        value: 'Mexico',
                        disabled: true,
                        key: '1-2',
                    },
                    {
                        label: 'Cuba',
                        value: 'Cuba',
                        key: '1-3',
                    },
                ],
            },
        ];
    
        const [v, $v] = useState<Array<string | number>>(['Shanghai']);
    
        return (
            <div style={{ margin: 10, padding: 10, width: 600 }}>
                <Transfer dataSource={treeData} type="treeList" value={v} onChange={$v} />
            </div>
        );
    }

    Tree Transfer with Custom Header Showing Leaf Node Count

    When type is treeList, the SourceHeaderProps parameter of renderSourceHeader provides an additional leafOnlyNum field, which represents the number of leaf nodes. This is useful in scenarios like file selection, where you can display only the file count instead of the total including folders.

    文件总数:7 个文件(总节点数:10)
  • 文件夹 1
  • 文件 1-1
  • 文件 1-2
  • 子文件夹 1
  • 文件 1-1-1
  • 文件 1-1-2
  • 文件夹 2
  • 文件 2-1
  • 文件 2-2
  • 独立文件
  • 已选个数:0
    暂无内容,可从左侧勾选
    Code
    import { useState } from 'react';
    import { Transfer, Button, type TransferProps } from '@fibrous/semi-ui-react';
    
    export default function TransferDemo() {
        const treeData = [
            {
                label: '文件夹 1',
                value: 'folder1',
                key: 'folder1',
                children: [
                    {
                        label: '文件 1-1',
                        value: 'file1-1',
                        key: 'file1-1',
                    },
                    {
                        label: '文件 1-2',
                        value: 'file1-2',
                        key: 'file1-2',
                    },
                    {
                        label: '子文件夹 1',
                        value: 'subfolder1',
                        key: 'subfolder1',
                        children: [
                            {
                                label: '文件 1-1-1',
                                value: 'file1-1-1',
                                key: 'file1-1-1',
                            },
                            {
                                label: '文件 1-1-2',
                                value: 'file1-1-2',
                                key: 'file1-1-2',
                            },
                        ],
                    },
                ],
            },
            {
                label: '文件夹 2',
                value: 'folder2',
                key: 'folder2',
                children: [
                    {
                        label: '文件 2-1',
                        value: 'file2-1',
                        key: 'file2-1',
                    },
                    {
                        label: '文件 2-2',
                        value: 'file2-2',
                        key: 'file2-2',
                    },
                ],
            },
            {
                label: '独立文件',
                value: 'file3',
                key: 'file3',
            },
        ];
    
        const [value, setValue] = useState<Array<string | number>>([]);
    
        const renderSourceHeader: TransferProps['renderSourceHeader'] = ({ num, leafOnlyNum, showButton, allChecked, onAllClick }) => {
            return (
                <div
                    style={{
                        display: 'flex',
                        justifyContent: 'space-between',
                        alignItems: 'center',
                        padding: '8px 12px',
                        borderBottom: '1px solid var(--semi-color-border)',
                    }}
                >
                    <span>
                        <strong>文件总数:</strong>
                        {leafOnlyNum !== undefined ? leafOnlyNum : num} 个文件
                        {leafOnlyNum !== undefined && <span style={{ color: 'var(--semi-color-text-2)', marginLeft: 8, fontSize: 12 }}>(总节点数:{num})</span>}
                    </span>
                    {showButton && (
                        <Button theme="borderless" type="tertiary" size="small" onClick={onAllClick}>
                            {allChecked ? '取消全选' : '全选'}
                        </Button>
                    )}
                </div>
            );
        };
    
        return <Transfer style={{ width: 600 }} dataSource={treeData} type="treeList" value={value} onChange={setValue} renderSourceHeader={renderSourceHeader} />;
    }

    Accessibility

    ARIA

    • The container of the search box is a native search element (the search landmark), named from the locale
    • When the root element has aria-label or aria-labelledby and no role, it gets role group
    • Add role list to the option list on the left and listitem to its options; in groupList every group is a listitem of the outer list, and its title names the nested list that holds the options
    • Add role list to the selected list on the right, add role listitem to the selected item; custom rendered items on either side are wrapped in an element with role listitem

    Keyboard

    • The default filter ignores case
    • When disabled, the two lists are Tab stops so the keyboard can scroll their content
    • With draggable, the drag handle is a native button with a name: Tab focuses the handle, Space picks up, the arrow keys move, Space drops; the sort is announced to screen readers. Mouse dragging is unchanged
    • Until the dnd-kit needed for sorting has loaded, the handle is a placeholder with aria-disabled="true"

    API Reference

    Transfer

    Props

    PropertyDescriptionTypeDefault
    classNameClass name of the root element.string-
    dataSourceData source: an array of items for list, an array of groups for groupList, or tree data with children for treeList.DataSource[]
    defaultValueValues selected initially, read once when the transfer is created.TypeArray<string | number>[]
    disabledWhether the whole transfer is disabled, including the search box, the options and the action buttons.boolean-
    draggableEnables drag sorting of the selected items on the right. After a sort, the order of the array passed to onChange changes.boolean-
    emptyContentCustom empty-state content: left when the left list has no data, right when nothing is selected, search when the search matches nothing. A null entry hides that empty state; a missing one shows the locale text.EmptyContent{}
    filterFiltering of the search. false hides the search box; a function replaces the default case-insensitive match on label and returns true to keep an item. For a custom search in treeList, set it to true and pass the matching function as filterTreeNode in treeProps.Typeboolean | ((searchValue: string, item: DataItem) => boolean)-
    inputPropsProps passed to the search Input, see Input for the options. value and onChange belong to Transfer; to search from outside, call the search method on the ref.InputProps-
    loadingWhether the options on the left are loading; a Spin replaces the list while they load.boolean-
    onChangeCalled when the selection changes, including after a drag sort, with the array of values and the array of their items.Type(values: Array<string | number>, items: Array<DataItem>) => void-
    onDeselectCalled when an item is unchecked, with that item.Type(item: DataItem) => void-
    onSearchCalled when the text of the search box changes, with the search value. A search driven by the ref's search method does not call it.Type(searchValue: string) => void-
    onSelectCalled when an item is checked, with that item.Type(item: DataItem) => void-
    paginationPaging of the left panel, for list and groupList only. onPageChange lives inside the object.PaginationProps-
    refReceives a TransferHandle that exposes only the search method; it is not the root element.TypeReact.Ref<TransferHandle>-
    renderSelectedHeaderReplaces the header of the right panel; called on every render with SelectedHeaderProps.Type(headProps: { num: number; showButton: boolean; onClear: () => void; }) => React.ReactNode-
    renderSelectedItemRenders one selected item on the right, called once per item on every render. The argument is the item plus onRemove; with draggable it also has sortableHandle. With treeList and showPath, fullPath holds the whole path.Type(item: RenderSelectedItemProps) => React.ReactNode-
    renderSelectedPanelReplaces the whole right panel; called on every render with SelectedPanelProps.Type(selectedPanelProps: SelectedPanelProps) => React.ReactNode-
    renderSourceHeaderReplaces the header of the left panel; called on every render with SourceHeaderProps. leafOnlyNum is provided for treeList only.Type(headProps: { num: number; showButton: boolean; allChecked: boolean; onAllClick: () => void; leafOnlyNum?: number; }) => React.ReactNode-
    renderSourceItemRenders one candidate on the left, called once per item on every render. The argument is the item plus checked and onChange, which toggles the checked state of the item.Type(item: RenderSourceItemProps) => React.ReactNode-
    renderSourcePanelReplaces the whole left panel; called on every render with SourcePanelProps.Type(sourcePanelProps: SourcePanelProps) => React.ReactNode-
    showPathtreeList only: whether the selected items on the right show their path from the root.booleanfalse
    styleInline style of the root element.React.CSSProperties-
    treePropstreeList only: props passed to the Tree on the left, overriding the defaults multiple, disableStrictly, leafOnly, filterTreeNode, defaultExpandAll and searchRender (false). value, treeData, keyMaps, treeDataSimpleJson, onChangeWithObject, onChange and ref belong to Transfer and are ignored.TypeOmit<TreeProps, 'value' | 'ref' | 'onChange' | 'keyMaps' | 'treeData' | 'treeDataSimpleJson' | 'onChangeWithObject'>-
    typeTransfer type: list, groupList or treeList.Type"list"
    valueValues of the selected items. Passing it makes the component controlled, and its order is the order on the right; undefined returns to uncontrolled.TypeArray<string | number>-
    virtualizeVirtualizes the selected list on the right, only with the default right panel and draggable off. A numeric height applies in pixels; any other value is measured from the remaining panel height. itemSize is the height of each row.VirtualizeProps-

    Methods

    MethodDescriptionType
    searchSearches as if the value were typed into the search box, and puts the value there; onSearch is not called.Type(value: string) => void

    Native attributes not listed above, such as id, aria-* and event handlers, land on the root div; with aria-label or aria-labelledby and no role, the root element gets role="group". tabIndex is set on the search box, including a value injected by a wrapping Tooltip. Pass the props of the search box through inputProps, and those of the left Tree of a treeList through treeProps.

    In @fibrous/semi-ui-react, the types of the interfaces below are exported as TransferDataItem for Item, TransferGroupItem for GroupItem and TransferTreeItem for TreeItem.

    Item Interface

    propsdescriptiondata typedefault
    disabledWhether to disablebooleanfalse
    keyRequired, unique identification of each option, no repetition is allowedstring | number
    labelOptions display contentReactNode
    fullPathWhen type="treeList" and showPath is true, returns the full path node array from the root node to the current nodeArray<Item>
    valueThe value represented by the optionstring | number

    GroupItem Interface

    A group is not an item itself, it only has the following properties

    propsdescriptiondata typedefault
    childrenElements of the grouparray<Item>
    titleGroup Namestring

    TreeItem Interface

    TreeItem inherits all the properties of Item

    propsdescriptiondata typedefault
    childrenChildren Itemsarray<TreeItem>

    VirtualizeProps Interface

    propsdescriptiondata typedefault
    heightHeight of the virtualized list. If it is a number, it takes effect directly. If it is a string (e.g. 100%), it adapts to remaining heightnumber | string
    widthWidth of the virtualized listnumber | string
    itemSizeFixed height of each item rownumber

    PaginationProps Interface

    propsdescriptiondata typedefault
    currentPageCurrent page number (controlled mode)number
    defaultCurrentPageDefault current page number (uncontrolled mode)number1
    pageSizeNumber of items per pagenumber10
    onPageChangeCallback when page changes(currentPage: number) => void

    Methods

    Methods on the TransferHandle that ref receives can be called through the ref:

    const transferRef = useRef<TransferHandle>(null);
    
    <Transfer ref={transferRef} />;
    
    transferRef.current?.search('Option 1');

    Design Tokens

    These are the component's internal Sass variables and cannot be overridden. To customize styles, override the --semi-* CSS variables (see the Design Token page) or write unlayered CSS rules.
    Sass variableValueUsage
    $transition_duration_transfer_item-bgvar(--semi-transition_duration-none)穿梭框条目-背景色-动画持续时间
    $transition_function_transfer_item-bgvar(--semi-transition_function-easeIn)穿梭框条目-背景色-过渡曲线
    $transition_delay_transfer_item-bgvar(--semi-transition_delay-none)穿梭框条目-背景色-延迟时间
    $color-transfer-bgvar(--semi-color-bg-1)穿梭框背景颜色 - 默认
    $color-transfer-bordervar(--semi-color-border)穿梭框描边颜色 - 默认
    $color-transfer_header-textvar(--semi-color-text-2)穿梭框 header 文字颜色
    $color-transfer_empty-textvar(--semi-color-text-2)穿梭框空状态文字颜色
    $color-transfer_group_title-textvar(--semi-color-text-2)穿梭框分组标题文字颜色
    $color-transfer_disabled-textvar(--semi-color-disabled-text)穿梭框禁用文本文字颜色
    $color-transfer_close_icon-iconvar(--semi-color-text-2)穿梭框关闭按钮颜色
    $color-transfer_item-textvar(--semi-color-text-1)穿梭框常规文字颜色
    $color-transfer_selected_item-textvar(--semi-color-text-0)穿梭框选中条目文字颜色
    $color-transfer_item-bg-hovervar(--semi-color-fill-0)穿梭框条目背景色 - 悬浮
    $color-transfer_item-bg-activevar(--semi-color-fill-1)穿梭框条目背景色 - 按下
    $width-transfer-border1px穿梭框描边宽度
    $width-transfer-minWidth402px穿梭框整体最小宽度
    $height-transfer400px穿梭框高度
    $height-transfer_header24px穿梭框 header 高度
    $height-transfer_item-minHeight36px穿梭框条目最小高度
    $width-transfer_item_close-icon$width-icon-small穿梭框选中条目删除按钮宽度
    $width-transfer_left50%穿梭框左侧面板宽度
    $width-transfer_right50%穿梭框左侧面板宽度
    $height-transfer_left_empty36px穿梭框空状态高度
    $width-transfer_left-border$border-thickness-control穿梭框双侧面板分割线宽度
    $height-transfer_right_header32px穿梭框 header 高度
    $height-transfer_right_empty100%穿梭框右侧空状态宽度
    $width-transfer_empty100%穿梭框整体空状态宽度
    $height-transfer_group_title28px穿梭框分组标题高度
    $spacing-transfer_header-marginTop12px穿梭框 header 顶部外边距
    $spacing-transfer_header-marginRight12px穿梭框 header 右侧外边距
    $spacing-transfer_header-marginBottom8px穿梭框 header 底部外边距
    $spacing-transfer_header-marginLeft12px穿梭框 header 左侧外边距
    $spacing-transfer_header_all-marginLeft$spacing-base穿梭框全选按钮左侧外边距
    $spacing-transfer_item-paddingTop$spacing-tight穿梭框条目顶部内边距
    $spacing-transfer_item-paddingRight9px穿梭框条目右侧内边距
    $spacing-transfer_item-paddingBottom$spacing-tight穿梭框条目底部内边距
    $spacing-transfer_item-paddingLeft$spacing-base-tight穿梭框条目左侧内边距
    $spacing-transfer_right_header-marginTop$spacing-base-tight穿梭框右侧面板 header 顶部外边距
    $spacing-transfer_right_header-marginBottom0穿梭框右侧面板 header 底部外边距
    $spacing-transfer_right_item_drag_handler-marginRight4px穿梭框拖动图标右侧外边距
    $spacing-transfer_filter-marginTop12px穿梭框搜索顶部外边距
    $spacing-transfer_filter-marginRight12px穿梭框搜索右侧外边距
    $spacing-transfer_filter-marginBottom0穿梭框搜索底部外边距
    $spacing-transfer_filter-marginLeft12px穿梭框搜索左侧外边距
    $spacing-transfer_group_title-paddingLeft$spacing-base-tight穿梭框分组标题左侧内边距
    $radius-transfervar(--semi-border-radius-medium)穿梭框圆角
    $font-transfer_header_all-fontWeight600穿梭框字重