Input · 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


How to import

Basic Usage

dataSource should have value、label、key.


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

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. 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


Drag and drop sort

Set draggable to true to enable the drag sort function. Support after v1.11.0

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 (sortableHandle is provided after v 1.22.0)

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
renderSelectedPanel: (selectedPanelProps: SelectedPanelProps) => ReactNode SelectedPanelProps contains the following parameters

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, we recommend using react-sortable-hoc directly To support drag sorting, you need to call onSortEnd with oldIndex and newIndex as the input parameters after the drag sorting is over

Tree Transfer

The input type is treeList, and the Tree component is used as a custom rendering list. v1.20.0 available
The properties of the default tree can be overridden by treeProps(TreeProps). The default properties of the tree on the left are



  • Add role search to the search box
  • Add role list to the selected list on the right, add role listitem to the selected item

API Reference

Trasnfer Props

propsdescriptiondata typedefaultversion
classNameStyle class namestring
dataSourceData SourceArray<Item>|Array<GroupItem>|Array<TreeItem>[]
defaultValueDefault selected valueArray<string|number>
disabledWhether to disablebooleanfalse
draggableWhether to enable drag sortingbooleanfalse
emptyContentCustom empty state prompt text, search is the text displayed when there are no search results, left is the text when there is no source data on the left, and right is the prompt text when no data is checked{left: ReactNode; right: ReactNode; search: ReactNode;}
filterCustom filter logic, when false, the search box is not displayedboolean | (input:string, item: Item) => booleantrue
inputPropsCan be used to customize the search box Input, the configurable properties refer to the Input componentInputProps
loadingWhether the left option is being loadedboolean-
onChangeThe callback that is triggered when the selected value changes, and the callback is also triggered after the drag sort changes(values: Array<string|number>, items: Array<Item>) => void
onDeselectCallback when unchecking(item: Item) => void
onSearchCalled when the input content of the search box changes(inputValue: string) => void
onSelectCallback when checked(item: Item) => void
renderSelectedItemCustomize the rendering of a single selected item on the right(item: {onRemove, sortableHandle} & Item) => ReactNode
renderSelectedPanelCustomize the rendering of the selected panel on the right(selectedPanelProps) => ReactNode1.11.0
renderSourceItemCustomize the rendering of a single candidate item on the left(item: {onChange, checked} & Item) => ReactNode
renderSourcePanelCustomize the rendering of the left candidate panel(sourcePanelProps) => ReactNode1.11.0
showPathWhen the type is treeList, control whether the selected item on the right shows the selection pathbooleanfalse1.20.0
styleInline styleCSSProperties
treePropsWhen the type is treeList, it can be passed as TreeProps to the Tree component on the leftTreeProps1.20.0
typeTransfer type, optional list, groupList, treeListstring'list'1.20.0
valueThe selected value, when the item is passed in, it will be used as a controlled componentArray<string|number>

Item Interface

propsdescriptiondata typedefaultversion
classNameStyle class namestring
disabledWhether to disablebooleanfalse
keyRequired, unique identification of each option, no repetition is allowedstring | number
labelOptions display contentReactNode
styleInline styleCSSProperties
valueThe value represented by the optionstring | number

GroupItem Interface

GroupItem inherits all the properties of Item
propsdescriptiondata typedefaultversion
childrenElements of the grouparray<Item>
titleGroup Namestring

TreeItem Interface

TreeItem inherits all the properties of Item
propsdescriptiondata typedefault
childrenChildren Itemsarray<TreeItem>

Design Tokens

© 2021 - 2022 Semi Design. All rights reserved.

京ICP备19058139号-13浙公网安备 33011002016131号

Designed & Developed with love by Douyin FE & MED