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
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.
<script lang="ts">
import { Transfer, type TransferDirection, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2']);
let lastMove = $state(("No transfers"));
function handleChange(next: TransferKey[], direction: TransferDirection, moved: TransferKey[]) {
targetKeys = next;
lastMove = ("" + String((direction)) + ": " + String((moved.join(', '))) + "");
}
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
</style>
<div
class="lists"
role="region"
aria-label={("Lists: Transfer between lists")}
tabindex="0"
>
<Transfer dataSource={(dataSource)} {targetKeys} titles={([
"Available",
"Selected"
])} actions={(["Add", "Return"])}
render={item => item.title} onChange={handleChange} />
</div>
<p><output aria-label={("Transfer result")}>{(targetKeys.join(', ')
|| ("Empty"))}; {lastMove}</output></p>
- Item 2
- Item 3
One way
oneWay leaves one transfer button. Elements from the right list are removed using separate buttons.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2', '3']);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
</style>
<div class="lists" role="region" aria-label={("Lists: One way")} tabindex="0">
<Transfer dataSource={(dataSource)} {targetKeys} oneWay actions={([
"Add"
])} titles={(["Available", "Selected"])}
render={item => item.title} onChange={next => { targetKeys = next; }} />
</div>
<p><output aria-label={("Single-sided selection")}>{targetKeys.join(', ')}</output></p>
Independent search
Each list stores its own request. filterOption searches by name and description; onSearch reports the side and string.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2', '5']);
let query = $state('');
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
</style>
<div
class="lists"
role="region"
aria-label={("Lists: Independent Search")}
tabindex="0"
>
<Transfer
dataSource={(dataSource)}
{targetKeys}
showSearch={{ placeholder: "Name or description" }}
titles={(["Available", "Selected"])}
actions={(["Add", "Return"])}
render={item => item.title}
filterOption={(search, item) => `${item.title} ${item.description}`.toLowerCase().includes(
search.toLowerCase()
)}
onSearch={(direction, search) => { query = ("" + String((direction)) + ": " + String((search)) + ""); }}
onChange={next => { targetKeys = next; }}
/>
</div>
<p><output
aria-label={("Search Transfer")}
>{(query || ("Search not specified"))}</output></p>
List footer
footer receives list and direction parameters. The button deselects its side; general disabled blocks actions.
<script lang="ts">
import {
Button,
Transfer,
type TransferDirection,
type TransferKey,
type TransferListProps
} from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2']);
let disabled = $state(false);
type Row = typeof dataSource[number];
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
.footer { padding: 8px 12px; }
</style>
<p>
<label><input type="checkbox" bind:checked={disabled} />{(" Block both lists")}</label>
</p>
{#snippet footer(list: TransferListProps<Row>, info: { direction: TransferDirection })}
<div class="footer"><Button
size="small"
disabled={list.disabled}
onclick={() => list.onItemSelectAll(list.checkedKeys, false)}
>{("Deselect ")}{(info.direction)}</Button></div>
{/snippet}
<div class="lists" role="region" aria-label={("Lists: List footer")} tabindex="0">
<Transfer
dataSource={(dataSource)}
{targetKeys}
{disabled}
{footer}
titles={(["Available", "Selected"])}
render={item => item.title}
actions={(["Add", "Return"])}
onChange={next => { targetKeys = next; }}
/>
</div>
Your data and labels
rowKey reads the numeric id. render returns label snippet and value for text metadata; the keys remain numbers.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
interface Person { id: number; name: string; role: string; }
const dataSource: Person[] = [
{ id: 10, name: "Anna", role: "Development" },
{ id: 20, name: "Boris", role: "Documentation" }
];
let targetKeys = $state<TransferKey[]>([]);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
</style>
{#snippet label(person: Person)}
<strong>
{person.name}
</strong>
<small>
{(person.role)}
</small>
{/snippet}
<div
class="lists"
role="region"
aria-label={("Lists: Your data and labels")}
tabindex="0"
>
<Transfer
dataSource={(dataSource)}
{targetKeys}
rowKey={person => person.id}
titles={(["Members", "Team"])}
actions={(["To the team", "Return"])}
render={person => ({ label, value: person.name })}
onChange={next => { targetKeys = next; }}
/>
</div>
<p><output aria-label={("Participant keys")}>{JSON.stringify(targetKeys)}</output></p>
Your own transfer buttons
Snippet action gets disabled, direction, icon and onClick. Pass them to your Button, maintaining the regular transfer.
<script lang="ts">
import { Button, Transfer, type TransferActionInfo, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>([]);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
</style>
{#snippet action(info: TransferActionInfo)}
<Button
size="small"
disabled={info.disabled}
onclick={info.onClick}
aria-label={(info.direction === 'right' ? "Send to right" : "Return left")}
>{@render info.icon()}</Button>
{/snippet}
<div
class="lists"
role="region"
aria-label={("Lists: Own transfer buttons")}
tabindex="0"
>
<Transfer dataSource={(dataSource)} {targetKeys} actions={([
action,
action
])} titles={(["Available", "Selected"])}
render={item => item.title} onChange={next => { targetKeys = next; }} />
</div>
<p><output aria-label={("Choice with your actions")}>{(targetKeys.join(', ')
|| ("Empty"))}</output></p>
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.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
const items = ['Button', 'Input', 'Select', 'Tabs'].map(title => ({ key: title, title }));
const border = '1px solid var(--ant-color-border, #d9d9d9)';
let query = $state('');
let checkedKeys = $state<TransferKey[]>([]);
let targetKeys = $state<TransferKey[]>([]);
const available = $derived(items.filter(item =>
!targetKeys.includes(item.key) && item.title.toLowerCase().includes(query.trim().toLowerCase())
));
function handleFilter(event: Event & { currentTarget: HTMLInputElement }) {
query = event.currentTarget.value;
}
function handleClear() {
query = '';
}
function selectItem(key: TransferKey, selected: boolean) {
checkedKeys = selected
? [...checkedKeys, key]
: checkedKeys.filter(checked => checked !== key);
}
function move() {
targetKeys = [...targetKeys, ...checkedKeys];
checkedKeys = [];
}
</script>
<div class="example">
<Transfer.Search
aria-label={("Find a component")}
placeholder={("Find a component")}
value={query}
onChange={handleFilter}
{handleClear}
/>
<Transfer.List
prefixCls="available"
direction="left"
dataSource={available}
{checkedKeys}
titleText={("Available")}
notFoundContent={("No data")}
showSelectAll={false}
classNames={{}}
styles={{
section: {
border,
borderRadius: '8px',
minHeight: '172px'
},
header: {
display: 'flex',
flexDirection: 'row-reverse',
justifyContent: 'space-between',
padding: '8px 12px',
borderBottom: border
},
list: {
margin: 0,
padding: 0,
listStyle: 'none'
},
item: {
display: 'flex',
alignItems: 'center',
gap: '8px',
padding: '6px 12px'
}
}}
{handleFilter}
{handleClear}
onItemSelect={selectItem}
onItemSelectAll={() => {}}
onScroll={() => {}}
render={item => item.title}
/>
<Transfer.Operation
oneWay
actions={[("Add")]}
rightActive={checkedKeys.length > 0}
moveToRight={move}
/>
<p><output aria-label={("Selected")}>{targetKeys.join(', ') || ("Empty")}</output></p>
</div>
<style>
.example {
display: grid;
gap: 12px;
}
p {
margin: 0;
}
</style>
Page lists
pagination limits the visible lines of each side. Search and swipe save selected keys.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>([]);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
</style>
<div
class="lists"
role="region"
aria-label={("Lists: Page lists")}
tabindex="0"
>
<Transfer dataSource={(dataSource)} {targetKeys} pagination={({
pageSize: 3,
simple: false,
showSizeChanger: true
})}
titles={(["Available", "Selected"])} actions={([
"Add",
"Return"
])} render={item => item.title}
onChange={next => { targetKeys = next; }} />
</div>
<p><output aria-label={("Page selection")}>{(targetKeys.join(', ')
|| ("Empty"))}</output></p>
Name | Description | |
|---|---|---|
| Item 1 | Description 1 | |
| Item 2 | Description 2 | |
| Item 3 | Description 3 | |
| Item 4 | Description 4 | |
| Item 5 | Description 5 | |
| Item 6 | Description 6 | |
| Item 7 | Description 7 | |
| Item 8 | Description 8 |
Name | Description | |
|---|---|---|
No data | ||
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.
<script lang="ts">
import {
Table,
Transfer,
type TableColumn,
type TransferKey,
type TransferListBodyProps
} from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
interface Row { key: string; title: string; description: string; disabled: boolean; }
const columns: TableColumn<Row>[] = [
{ key: 'title', title: "Name", dataIndex: 'title' },
{ key: 'description', title: "Description", dataIndex: 'description' }
];
let targetKeys = $state<TransferKey[]>([]);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
</style>
<div
class="lists"
role="region"
aria-label={("Lists: Transfer with tables")}
tabindex="0"
>
<Transfer dataSource={(dataSource)} {targetKeys} titles={([
"Available",
"Selected"
])} showSelectAll={false}
styles={{ section: `
width: 360px;
height: 300px;
` }} actions={([
"Add",
"Return"
])}
onChange={next => { targetKeys = next; }}>
{#snippet children(list: TransferListBodyProps<Row>)}
<Table
dataSource={(list.filteredItems)}
columns={(columns)}
rowKey="key"
pagination={(false)}
selectedRowKeys={list.selectedKeys.map(String)}
disabled={list.disabled}
rowSelection={{
getCheckboxProps: row => ({
disabled: row.disabled,
'aria-label': row.title
})
}}
onSelectionChange={keys => list.onItemSelectAll(keys, 'replace')}
/>
{/snippet}
</Transfer>
</div>
<p><output aria-label={("Table selection")}>{(targetKeys.join(', ')
|| ("Empty"))}</output></p>
Select items in the catalog
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.
<script lang="ts">
import {
Checkbox,
Transfer,
Tree,
type TransferKey,
type TransferListBodyProps,
type TreeDataNode
} from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
interface Row { key: string; title: string; description: string; disabled: boolean; }
let targetKeys = $state<TransferKey[]>([]);
function asTree(records: readonly Row[]): TreeDataNode[] {
return [{ key: 'group', title: "Catalog", checkable: false, selectable: false,
children: records.map(row => ({ key: row.key, title: row.title, disabled: row.disabled }))
}];
}
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
.target {
display: grid;
gap: 12px;
padding: 12px;
}
</style>
<div
class="lists"
role="region"
aria-label={("Lists: Carrying with wood")}
tabindex="0"
>
<Transfer dataSource={(dataSource)} {targetKeys} titles={([
"Catalog",
"Selected"
])} showSelectAll={false}
styles={{ section: `
width: 260px;
height: 280px;
` }} actions={([
"Add",
"Return"
])}
onChange={next => { targetKeys = next; }}>
{#snippet children(list: TransferListBodyProps<Row>)}
{#if list.direction === 'left'}
<Tree aria-label={("Tree of available items")} treeData={asTree(
list.filteredItems
)} checkable checkStrictly
defaultExpandAll checkedKeys={list.selectedKeys.map(String)} disabled={list.disabled}
onCheck={(_keys, info) => list.onItemSelect(info.node.key, info.checked)} />
{:else}
<div class="target">
{#each list.filteredItems as row (row.key)}
<Checkbox checked={list.selectedKeys.includes(row.key)} disabled={list.disabled
|| row.disabled}
onChange={event => list.onItemSelect(row.key, event.target.checked)}>{(row.title)}</Checkbox>
{:else}<p>{("Select items in the catalog")}</p>{/each}
</div>
{/if}
{/snippet}
</Transfer>
</div>
<p><output aria-label={("Wood selection")}>{(targetKeys.join(', ')
|| ("Empty"))}</output></p>
Test states
status specifies error or warning. Inherited FormItem status is also supported.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2']);
let warning = $state(true);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
</style>
<div
class="lists"
role="region"
aria-label={("Lists: Check states")}
tabindex="0"
>
<Transfer dataSource={(dataSource)} {targetKeys} status="error" titles={(["Error", "Selected"])}
render={item => item.title} onChange={next => { targetKeys = next; }} />
</div>
<p><label><input
type="checkbox"
bind:checked={warning}
/>{(" Show warning")}</label></p>
<div
class="lists"
role="region"
aria-label={("Lists: Check states")}
tabindex="0"
>
<Transfer
dataSource={(dataSource)}
{targetKeys}
status={warning ? 'warning' : ''}
titles={(["Check", "Selected"])}
render={item => item.title}
onChange={next => { targetKeys = next; }}
/>
</div>
Semantic slots
styles and classNames support common slots and separate source/target. The function receives info.props.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2']);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
</style>
<div class="lists" role="region" aria-label={("Lists: Semantic slots")} tabindex="0">
<Transfer dataSource={(dataSource)} {targetKeys} titles={([
"Source",
"Purpose"
])} actions={(["Add", "Return"])}
render={item => item.title} classNames={{ title: 'documented-transfer-title' }}
styles={({ props }) => ({
section: 'border-style:dashed',
itemContent: 'font-weight:600',
source: { header: 'background:var(--ant-color-fill-secondary)' },
target: { header: props.disabled ? '' : 'background:var(--ant-color-primary-bg)' }
})} onChange={next => { targetKeys = next; }} />
</div>
Blocked transfer
disabled blocks selection and actions; an inaccessible line is not transferred along with the available ones.
<script lang="ts">
import { Transfer, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2']);
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
</style>
<div
class="lists"
role="region"
aria-label={("Lists: Blocked transfer")}
tabindex="0"
>
<Transfer dataSource={(dataSource)} {targetKeys} disabled titles={([
"Available",
"Selected"
])}
render={item => item.title} onChange={next => { targetKeys = next; }} />
</div>
Selecting participants in Form
Form stores targetKeys explicitly. submit checks for a non-empty selection, reset restores the initial keys, and clears the selection.
<script lang="ts">
import { Button, Form, FormItem, Transfer, createForm, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 8 }, (_, index) => ({
key: String(index + 1),
title: `Item ${index + 1}`,
description: `Description ${index + 1}`,
disabled: index === 3
}));
const form = createForm<{ members: string[] }>({
initialValues: { members: ['2'] },
rules: ({ members: [{ required: true, message: "Select participants." }] })
});
let selectedKeys = $state<TransferKey[]>([]);
let result = $state('');
</script>
<style>
.lists {
max-width: 100%;
overflow-x: auto;
}
.lists:focus-visible {
outline: 2px solid var(--ant-color-primary);
outline-offset: 2px;
}
output { overflow-wrap: anywhere; }
.actions {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
</style>
<Form {form} onFinish={values => { result = values.members.join(', '); }}>
<FormItem hasFeedback name="members" label={("Team composition")}>
<div
class="lists"
role="region"
aria-label={("Lists: Selecting Members in Form")}
tabindex="0"
>
<Transfer
dataSource={(dataSource)}
targetKeys={form.values.members}
{selectedKeys}
titles={(["Available", "Team"])}
actions={(["Add", "Return"])}
render={item => item.title}
onChange={next => form.setFieldValue('members', next.map(String))}
onSelectChange={(left, right) => { selectedKeys = [...left, ...right]; }}
/>
</div>
</FormItem>
<div
class="actions"
><Button
type="primary"
htmlType="submit"
>{("Save command")}</Button><Button
htmlType="reset"
onclick={() => { selectedKeys = []; }}
>{("Reset command")}</Button></div>
</Form>
<p><output aria-label={("Saved command")}>{(result
|| ("Not sent"))}</output></p>
- /2
- /1
Tasks to work
Original example from the review: controlled selection, search, pages, oneWay and resetting two lists.
<script lang="ts">
import { Button, Transfer, type TransferKey } from '@woodger/antd';
const dataSource = Array.from({ length: 12 }, (_, index) => ({
key: String(index + 1),
title: `Problem ${index + 1}`,
description: `Description of the task ${index + 1}`,
disabled: index === 3
}));
let targetKeys = $state<TransferKey[]>(['2', '5']);
let selectedKeys = $state<TransferKey[]>([]);
let oneWay = $state(false);
</script>
<style>
.controls {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12px;
margin-bottom: 16px;
}
.controls label {
display: flex;
align-items: center;
gap: 8px;
}
.lists {
max-width: 100%;
overflow-x: auto;
}
output {
display: block;
margin-top: 16px;
overflow-wrap: anywhere;
}
</style>
<div class="controls">
<label><input
type="checkbox"
bind:checked={oneWay}
/>{(" One way only")}</label>
<Button onclick={() => {
targetKeys = ['2', '5'];
selectedKeys = [];
}}>{("Reset lists")}</Button>
</div>
<div class="lists">
<Transfer
dataSource={(dataSource)}
{targetKeys}
{selectedKeys}
{oneWay}
titles={(["Available", "Selected"])}
actions={["Select tasks", "Return tasks"]}
showSearch={{ placeholder: "Find task" }}
render={item => item.title}
pagination={({ pageSize: 5 })}
styles={{ section: `
width: 240px;
height: 300px;
` }}
onChange={next => { targetKeys = next; }}
onSelectChange={(source, target) => { selectedKeys = [...source, ...target]; }}
/>
</div>
<output aria-label={("Transferred tasks")}>{targetKeys.length ? targetKeys.map(
key => `Problem ${key}`
).join(', ') : ("No tasks selected")}</output>
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.
<script lang="ts">
import { Checkbox, ConfigProvider, Transfer, type TransferKey } from '@woodger/antd';
let custom = $state(true);
let local = $state(true);
const prefix = $derived(custom ? 'suite' : 'ant');
const localPrefix = $derived(local ? 'project-transfer' : '');
let targetKeys = $state<TransferKey[]>(['docs']);
const dataSource = [
{ key: 'docs', title: "Documentation" },
{ key: 'examples', title: "Examples" }
];
</script>
<style>
.example,
.prefix-stage {
display: grid;
grid-template-columns: minmax(0, 1fr);
gap: 16px;
min-width: 0;
}
.controls {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
p { margin: 0; }
output { overflow-wrap: anywhere; }
.transfer-scroll {
min-width: 0;
max-width: 100%;
overflow-x: auto;
}
</style>
<div class="example">
<div class="controls">
<Checkbox bind:checked={custom}>{("General prefix Transfer suite")}</Checkbox>
<Checkbox bind:checked={local}>{("Local prefix Transfer")}</Checkbox>
</div>
<ConfigProvider prefixCls={prefix} theme={{ cssVar: { prefix: 'transfer-theme' } }}>
<div class="prefix-stage">
<div class="transfer-scroll">
<Transfer
prefixCls={localPrefix}
dataSource={(dataSource)}
{targetKeys}
showSearch
render={item => item.title}
titles={(["Available", "Selected"])}
onChange={keys => targetKeys = keys}
/>
</div>
<output aria-label={("Transfer selection with prefix")}>{(targetKeys.join(', ')
|| '—')}</output>
</div>
</ConfigProvider>
<output
aria-label={("CSS prefix Transfer")}
>{("General: ")}{prefix}{("; local: ")}{(localPrefix
|| ("from the provider"))}</output>
<p>
{("Transfer panels use a local prefix, and Checkbox, Input, Button and Pagination use an independent common one. Searches, marks and transferred entries are saved.")}
</p>
</div>
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.
| Property | Description | Type | Default |
|---|---|---|---|
prefixCls | Full 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. | string | ConfigProvider.prefixCls + "-transfer" |
dataSource | All entries for both sides, including those already selected. Keys must be unique. | readonly RecordType[] | [] |
targetKeys | Managed result. Accept onChange; There is no local defaultTargetKeys and bind:targetKeys. | readonly TransferKey[] | [] |
selectedKeys | Temporary selection of both sides. With onSelectChange you can control it explicitly. | readonly TransferKey[] | Local selection |
rowKey | Record key. TransferKey stores string, number or bigint. | (record) => TransferKey | record.key |
render | String, Svelte snippet with record or object. value specifies text metadata, label specifies content. | (record) => content | { label, value } | — |
onChange | New result, transfer direction and keys of moved records. | (targetKeys, direction, moveKeys) => void | — |
onSelectChange | Separates the temporary allocation of the source and target lists. | (sourceSelectedKeys, targetSelectedKeys) => void | — |
showSearch | Independent search strings on the sides. defaultValue is read when the list is created. | boolean | { placeholder, defaultValue } | false |
filterOption | Your own filter. onSearch reports the physical side and the search string. | (search, record, direction) => boolean | By text render |
oneWay | One transfer button; Remove from selected buttons appear on the target side. | boolean | false |
actions | Strings for regular buttons or snippets with onClick, disabled, direction and icon. | readonly TransferAction[] | Arrows |
pagination | pageSize, simple, showSizeChanger and showLessItems. Does not apply to children. | boolean | TransferPagination | false |
footer | Your own footer with the context of the list and its actions. | Snippet<[TransferListProps, { direction }]> | — |
children | Replaces the body of both sides. The application connects its controls to onItemSelect/onItemSelectAll. | Snippet<[TransferListBodyProps<RecordType>]> | Standard List |
titles | Headings of two lists. locale also changes search, counters, and commands. | readonly TransferContent[] | From locale |
showSelectAll | Shows the general selection. selectAllLabels replaces counter labels. | boolean | true |
disabled | Blocks all actions. The disabled entry is blocked separately. | boolean | From Form/ConfigProvider |
status | error or warning to check. An empty string inherits the field status. | TransferStatus | From FormItem |
styles | CSS strings and objects for shared parts and the individual source and target lists. classNames uses the same structure for classes. | TransferSemanticValue<CSSStyle> | — |
nativeElement | bind: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.
| Slots | Purpose |
|---|---|
root / actions | Root and transfer button area. |
section / header / title / body | List, title, text and body. |
list / item / itemIcon / itemContent / footer | Row list, row, icon, content and footer. |
source / target | Nested 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.
<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>
| Token | Purpose |
|---|---|
headerHeight | List title height. |
itemHeight | Minimum line height. |
itemPaddingBlock | Vertical line indents. |
listHeight | List height. |
listWidth | Width of a regular list. |
listWidthLG | Width of the extended list. |
Common tokens of the current topic
Values are read reactively via theme.useToken().
| Token | Current value |
|---|---|
colorBgContainer | #ffffff |
colorBgContainerDisabled | rgba(0,0,0,0.04) |
colorBorder | #d9d9d9 |
colorError | #ff4d4f |
colorLink | #1677ff |
colorLinkActive | #0958d9 |
colorLinkHover | #69b1ff |
colorPrimaryBorder | #adc6ff |
colorSplit | rgba(5,5,5,0.06) |
colorText | rgba(0,0,0,0.88) |
colorTextDisabled | rgba(0,0,0,0.25) |
colorTextSecondary | rgba(0,0,0,0.65) |
colorWarning | #faad14 |
borderRadiusLG | 8 |
controlHeightLG | 40 |
controlItemBgActive | #f0f5ff |
controlItemBgActiveHover | #d6e4ff |
controlItemBgHover | rgba(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' |
fontSize | 14 |
fontSizeIcon | 12 |
lineHeight | 1.5714285714285714 |
lineType | solid |
lineWidth | 1 |
lineWidthFocus | 3 |
linkDecoration | none |
linkFocusDecoration | none |
linkHoverDecoration | none |
marginXS | 8 |
marginXXS | 4 |
motionDurationSlow | 0.3s |
paddingSM | 12 |
paddingXS | 8 |
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.