For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/v/0.6.0/en/components/transfer.md.
  • English
  • Transfer

    Select and move items between two lists.

    Basic usage

    Available10
    Selected2
    basic.tsx
    import { Transfer } from '@ifhover/leaf-ui';
    
    import { useState } from 'react';
    
    export function TransferBasic() {
      const items = Array.from({ length: 12 }, (_, index) => ({
        key: String(index),
        label: `Resource ${index + 1}`,
        disabled: index === 4,
      }));
      const [value, setValue] = useState<readonly string[]>(['1', '3']);
      return <Transfer items={items} value={value} onChange={setValue} />;
    }
    

    More examples

    All members2000
    Team members0
    No items
    advanced.tsx
    import { Transfer } from '@ifhover/leaf-ui';
    
    import { useState } from 'react';
    
    export function TransferVirtual() {
      const [items] = useState(() =>
        Array.from({ length: 2000 }, (_, index) => ({
          key: String(index),
          label: `Member ${index + 1}`,
          description: index % 2 ? 'Designer' : 'Developer',
        })),
      );
      return <Transfer items={items} virtual height={240} titles={['All members', 'Team members']} />;
    }
    

    Usage

    value contains the keys in the right panel, while selectedKeys contains the checked items. Search, bulk transfer, one-way transfer and virtualization are supported. name submits a JSON array string.

    Types

    Import these types for data, callbacks and refs.

    import type { TransferChangeInfo, TransferItem, TransferProps } from '@ifhover/leaf-ui';

    TransferChangeInfo API

    PropertyTypeDefaultDescription
    direction'left' | 'right'RequiredLayout or movement direction
    movedKeysstring[]RequiredMoved keys

    TransferItem API

    PropertyTypeDefaultDescription
    keystringRequiredUnique stable identifier
    labelReactNodeRequiredDisplay label
    descriptionstring—Supporting description
    disabledboolean—Disable interactions
    searchLabelstring—Plain-text search label

    TransferProps API

    PropertyTypeDefaultDescription
    itemsreadonly TransferItem[]RequiredItems; keep keys unique and stable
    valuereadonly string[]—Controlled value
    defaultValuereadonly string[][]Initial value, restored by uncontrolled form resets
    onChange(keys: string[], info: TransferChangeInfo) => void—Value change callback
    selectedKeysreadonly string[]—Selected items to move
    onSelectionChange(keys: string[]) => void—Selection changes
    titlesreadonly [ReactNode, ReactNode]—Left and right titles
    searchablebooleantrueShow search inputs
    filterOption(query: string, item: TransferItem) => boolean—Custom search rule
    renderItem(item: TransferItem) => ReactNode—Custom item renderer
    disabledboolean—Disable interactions
    heightnumber180Height, numbers are in pixels
    virtualbooleanfalseRender visible items only
    namestring—Form field name
    formstring—Associated form ID
    requiredboolean—Required form validation
    oneWaybooleanfalseAllow moving right only