Ant Design Svelte

Transfer

Selecting records by transfer between two controlled lists.

When to use

Transfer selects a set of participants, permissions, or tasks by transferring between two lists. The user first marks the entries, then transfers them with one button. Two lists leave room for searching, describing and comparing available and already selected entries. For a compact tagged field, use Select.

On this page, wide lists scroll inside cards. Header and action labels should explain the meaning of the wrap, for example, “Available → Command.”

Transfer CSS prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. The Transfer panels use a local prefix, while Checkbox, Input, Button and Pagination use an independent common one. Searches, marks and transferred entries are saved.

Result and selection

targetKeys contains the result of the selection. selectedKeys contains temporarily marked rows on both sides. A checkbox by itself does not add an entry to the result.

Problem Setting Example
Accept transfer to model targetKeys, onChange Transfer between lists
Manage temporary allocation selectedKeys, onSelectChange List footer
Remove back button oneWay One way
Store the result in Form form.setFieldValue Selecting participants in Form

The result is always controlled by the application: pass targetKeys and assign a new array in onChange. The handler also receives direction and moveKeys - the direction of action and the keys of the moved records. Without assigning targetKeys, the right side will not change. There is no separate defaultTargetKeys or bind:targetKeys.

The selection can be left local or controlled via selectedKeys. onSelectChange reports two arrays: the source and destination list marks. The guided example combines them into one selectedKeys. Clearing the selection does not clear the result, and an external reset of the result does not replace the individual mark state.

In oneWay, the selected records are returned via the delete button on the right. It excludes the key from targetKeys, storing the entry in dataSource. disabled blocks transfer entirely or for an individual entry.

Data, search and pages

Each record needs a stable, unique key. If the ID is called something else, pass rowKey. Example of participants uses a numeric id without converting the model to a string. Do not use array position as an identifier when sorting or updating data.

render is a regular recording function. It returns text, a Svelte snippet, or an object with a label and a text value. In such an object, value describes the element to be displayed and does not replace its key. Snippet receives an entry as an argument; example participants shows name and role.

showSearch adds a separate search to each side. The settings object specifies the placeholder and the initial defaultValue; the subsequent request reports onSearch(direction, value). filterOption decides which local entries to show. Search example matches both title and description.

Pagination breaks local listings into pages; pageSize specifies their size. Page example retains marks when switching pages. Deleted requests, server page numbers, and response processing remain in the application. Store records of already selected keys in dataSource so that the target list can display their signatures.

Own lists and form

Use Transfer.Search, Transfer.List, and Transfer.Operation independently to build a custom interface. In the standalone components example, the application owns the search text, checked keys, and transfer result.

children accepts a Svelte snippet with TransferListBodyProps: filteredItems, selectedKeys, disabled, onItemSelect and onItemSelectAll. Table Transfer binds selectedRowKeys/onSelectionChange tables to these handlers. Tree Transfer links independent checkboxes of the tree. Be aware of disabled and pass real row keys rather than the entire original array.

Built-in pagination for children does not work. The application organizes the pages and navigation of its own body. For group replacement of marks, onItemSelectAll(keys, 'replace') is provided.

Your actions receive TransferActionInfo. Pass info.disabled and info.onClick to your button; info.icon already takes into account the direction of the interface. footer also accepts snippet. These functions are not replaced by React elements or cloneElement.

classNames styles and support common slots and separate source/target; styles accepts CSS strings and objects. ConfigProvider.transfer inherits the design and selectionsIcon. theme.components.Transfer component design tokens are applied to lists; local settings are shown in semantic example and token section.

In a form, the result is stored in form.values ​​and onChange calls form.setFieldValue. The required rule checks the target set. Reset form restores initialValues ​​and clears selectedKeys separately. Native checkboxes and buttons are accessible from the keyboard; bind:nativeElement returns the root div; Transfer does not have separate focus/blur methods.

Examples

7 items Available
1 item Selected

2; No transfers

Transfer between lists

Row selection and transferred keys are different states. targetKeys is always controlled by the application; onChange reports the direction and transferred keys.

6 items Available
2 items Selected
  • Item 2
  • Item 3

2, 3

One way

oneWay leaves one transfer button. Elements from the right list are removed using separate buttons.

List footer

footer receives list and direction parameters. The button deselects its side; general disabled blocks actions.

2 items Members
0 item Team
No data

[]

Your data and labels

rowKey reads the numeric id. render returns label snippet and value for text metadata; the keys remain numbers.

8 items Available
0 item Selected
No data

Empty

Your own transfer buttons

Snippet action gets disabled, direction, icon and onClick. Pass them to your Button, maintaining the regular transfer.

4 Available

Empty

Standalone Transfer components

Transfer.Search filters available records, Transfer.List displays them, and Transfer.Operation moves the checked items. The application owns both sets of keys.

8 items Available
0 item Selected
No data

Empty

Page lists

pagination limits the visible lines of each side. Search and swipe save selected keys.

8 items Available
0 item Selected

Empty

Transfer with tables

children replaces the body of the list with a public Table. selectedRowKeys and onSelectionChange are associated with onItemSelectAll; pagination Transfer does not work with children.

8 items Catalog
0 item Selected

Select items in the catalog

Empty

Carrying with wood

The source shows a tree of groups with independent checkboxes. The target party uses Checkbox; both bodies are connected to public callback Transfer.

7 items Error
1 item Selected

7 items Check
1 item Selected

Test states

status specifies error or warning. Inherited FormItem status is also supported.

7 items Source
1 item Purpose

Semantic slots

styles and classNames support common slots and separate source/target. The function receives info.props.

7 items Available
1 item Selected

Blocked transfer

disabled blocks selection and actions; an inaccessible line is not transferred along with the available ones.

7 items Available
1 item Team

Not sent

Selecting participants in Form

Form stores targetKeys explicitly. submit checks for a non-empty selection, reset restores the initial keys, and clears the selection.

10 items Available
  • /2
2 items Selected
  • /1
Задача 2, Задача 5

Tasks to work

Original example from the review: controlled selection, search, pages, oneWay and resetting two lists.

1 item Available
1 item Selected
docs
General: suite; local: project-transfer

Transfer panels use a local prefix, and Checkbox, Input, Button and Pagination use an independent common one. Searches, marks and transferred entries are saved.

CSS prefixes Transfer

Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.

API

Eleven themes of the live Transfer page on ant.design are presented in the cards above: basic and one-way transfer, search, footer, own data and actions, pages, Table/Tree, statuses and semantic slots. Additionally, disabled, Form, and tasks from the overview are shown.

Basic parameters Transfer
PropertyDescriptionTypeDefault
prefixClsFull CSS prefix of the component and its parts. A non-empty local prop takes precedence; empty string and undefined inherit ConfigProvider. The namespace of the topic is set separately.stringConfigProvider.prefixCls + "-transfer"
dataSourceAll entries for both sides, including those already selected. Keys must be unique.readonly RecordType[][]
targetKeysManaged result. Accept onChange; There is no local defaultTargetKeys and bind:targetKeys.readonly TransferKey[][]
selectedKeysTemporary selection of both sides. With onSelectChange you can control it explicitly.readonly TransferKey[]Local selection
rowKeyRecord key. TransferKey stores string, number or bigint.(record) => TransferKeyrecord.key
renderString, Svelte snippet with record or object. value specifies text metadata, label specifies content.(record) => content | { label, value }—
onChangeNew result, transfer direction and keys of moved records.(targetKeys, direction, moveKeys) => void—
onSelectChangeSeparates the temporary allocation of the source and target lists.(sourceSelectedKeys, targetSelectedKeys) => void—
showSearchIndependent search strings on the sides. defaultValue is read when the list is created.boolean | { placeholder, defaultValue }false
filterOptionYour own filter. onSearch reports the physical side and the search string.(search, record, direction) => booleanBy text render
oneWayOne transfer button; Remove from selected buttons appear on the target side.booleanfalse
actionsStrings for regular buttons or snippets with onClick, disabled, direction and icon.readonly TransferAction[]Arrows
paginationpageSize, simple, showSizeChanger and showLessItems. Does not apply to children.boolean | TransferPaginationfalse
footerYour own footer with the context of the list and its actions.Snippet<[TransferListProps, { direction }]>—
childrenReplaces the body of both sides. The application connects its controls to onItemSelect/onItemSelectAll.Snippet<[TransferListBodyProps<RecordType>]>Standard List
titlesHeadings of two lists. locale also changes search, counters, and commands.readonly TransferContent[]From locale
showSelectAllShows the general selection. selectAllLabels replaces counter labels.booleantrue
disabledBlocks all actions. The disabled entry is blocked separately.booleanFrom Form/ConfigProvider
statuserror or warning to check. An empty string inherits the field status.TransferStatusFrom FormItem
stylesCSS strings and objects for shared parts and the individual source and target lists. classNames uses the same structure for classes.TransferSemanticValue<CSSStyle>—
nativeElementbind:nativeElement returns the root. Individual focus()/blur() are not exported.HTMLDivElement—

Full Props definitions belong to the package. ReactNode and cloneElement in Svelte are replaced by snippets with explicitly passed handlers. Semantic styles contain CSS strings; styles.section styles both columns.

Own list body

children receives TransferListBodyProps: filteredItems, selectedKeys, disabled, direction, onItemSelect and onItemSelectAll. direction - physical side left/right and changes in RTL. The general header, search and transfer buttons remain with Transfer; the contents of the body are owned by the application.

Table Transfer connects public selectedRowKeys/onSelectionChange tables to list selection. In Svelte they are on the Table, not inside the React rowSelection.

Tree Transfer uses independent checkbox tree and checkbox list on the right. Marking a row calls onItemSelect; group table selection - onItemSelectAll(keys, 'replace'). Transfer's native pagination does not work for children: the application organizes its own body pages.

Semantic DOM

In a regular body, lines use native checkboxes, actions use buttons, search uses Input. The wide lists on this page scroll within a named area accessible from the keyboard. When composing, keep accessible names and disabled controls.

Semantic slots Transfer
SlotsPurpose
root / actionsRoot and transfer button area.
section / header / title / bodyList, title, text and body.
list / item / itemIcon / itemContent / footerRow list, row, icon, content and footer.
source / targetNested section slots for source and destination sides. Local slots overlap general slots.

classNames/styles can be an object or a function from info.props. ConfigProvider.transfer inherits class, style, classNames, styles and selectionsIcon. bind:nativeElement returns the root div; Transfer does not have separate focus methods.

Registration tokens

Six component tokens verified against ant.design and ComponentTokenMap['Transfer']. theme.components.Transfer applies the sizing and padding of lists. Semantic styles and ConfigProvider.transfer specify additional local settings.

1 item Available
1 item Selected
<script lang="ts">
  import { ConfigProvider, Transfer, type TransferKey } from '@woodger/antd';

  let targetKeys = $state<TransferKey[]>(['b']);
</script>

<style>
  .lists {
    max-width: 100%;
    overflow-x: auto;
  }
</style>

<ConfigProvider transfer={{
  styles: {
    section: `
      width: 220px;
      height: 220px;
    `,
    title: 'font-weight:600',
    target: { header: 'background:var(--ant-color-primary-bg)' }
  }
}}>
  <div
    class="lists"
    role="region"
    aria-label={("Registration of Transfer from the provider")}
    tabindex="0"
  >
    <Transfer dataSource={([{ key: 'a', title: "Development" }, {
      key: 'b',
      title: "Documentation"
    }])}
      {targetKeys} titles={(["Available", "Selected"])} actions={([
        "Add",
        "Return"
      ])}
      render={item => item.title} onChange={next => { targetKeys = next; }} />
  </div>
</ConfigProvider>
Component Transfer Tokens
TokenPurpose
headerHeightList title height.
itemHeightMinimum line height.
itemPaddingBlockVertical line indents.
listHeightList height.
listWidthWidth of a regular list.
listWidthLGWidth of the extended list.

Common tokens of the current topic

Values are read reactively via theme.useToken().

General Transfer Tokens
TokenCurrent value
colorBgContainer#ffffff
colorBgContainerDisabledrgba(0,0,0,0.04)
colorBorder#d9d9d9
colorError#ff4d4f
colorLink#1677ff
colorLinkActive#0958d9
colorLinkHover#69b1ff
colorPrimaryBorder#adc6ff
colorSplitrgba(5,5,5,0.06)
colorTextrgba(0,0,0,0.88)
colorTextDisabledrgba(0,0,0,0.25)
colorTextSecondaryrgba(0,0,0,0.65)
colorWarning#faad14
borderRadiusLG8
controlHeightLG40
controlItemBgActive#f0f5ff
controlItemBgActiveHover#d6e4ff
controlItemBgHoverrgba(0,0,0,0.04)
fontFamily-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSize14
fontSizeIcon12
lineHeight1.5714285714285714
lineTypesolid
lineWidth1
lineWidthFocus3
linkDecorationnone
linkFocusDecorationnone
linkHoverDecorationnone
marginXS8
marginXXS4
motionDurationSlow0.3s
paddingSM12
paddingXS8

FAQ

Why is the marked line not yet on the right?

Mark the line, press move and accept the new targetKeys in onChange. The selection and the result are stored separately.

What does deletion mean in oneWay?

Excludes a key from the target set. The entry is returned to the original list; data on the server is not deleted.

How to connect remote data?

Manage loading and server pages in the application. Leave records of the selected keys in the dataSource to display the target side; built-in search filters local data.

How to select a key from a field with a different name?

Pass rowKey, for example to a function that returns the member id. The key must remain unique on both sides and when the array is updated.