Examples

Invoice permissions

Preview
  • Draft invoices
  • Issue invoices
  • Read invoices
Example.tsx
import { useState } from 'react';
import { TransferList } from '@reactloom/dnd';

const permissions = [
  { id: 'read', label: 'Read invoices' },
  { id: 'draft', label: 'Draft invoices' },
  { id: 'issue', label: 'Issue invoices' },
];

export default function Example() {
  const [enabled, setEnabled] = useState(['read']);
  return (
    <TransferList items={permissions} value={enabled} onChange={setEnabled}
      sourceLabel="Available permissions" destinationLabel="Enabled permissions" />
  );
}

Assign reviewers

Preview
  • Priya Shah
  • Ana Silva

No reviewers in this list

Example.tsx
import { useState } from 'react';
import { TransferList } from '@reactloom/dnd';

const reviewers = [
  { id: 'priya', label: 'Priya Shah' },
  { id: 'ana', label: 'Ana Silva' },
];

export default function Example() {
  const [assigned, setAssigned] = useState<string[]>([]);
  return (
    <TransferList items={reviewers} value={assigned} onChange={setAssigned}
      sourceLabel="Available reviewers" destinationLabel="Assigned reviewers"
      messages={{ empty: 'No reviewers in this list' }} />
  );
}

API reference

TransferList props
PropTypeDefault
itemsrequired
All items with a unique, stable string id and a label.
readonly T[]—
valuerequired
IDs in the destination list. The items prop determines display order on both sides.
readonly string[]—
onChangerequired
Receives the updated membership. Update value to commit the transfer.
(ids: string[]) => void—
sourceLabel · destinationLabelrequired
Visible and accessible names for the two sides.
string—
disabled
Disable drag and move controls on both sides.
booleanfalse
messages
Translate action labels, empty text, and announcements.
Partial<TransferMessages>—
className
Apply a class to the outer element.
string—

Customization

Set a root className to apply local theme overrides such as --pl-color-border-default or --pl-focus-ring-color. Style an active drop zone with [data-drop-target] and the active handle with [data-dragging].

Accessibility

Each item has a move button and a drag handle. Focus follows the moved item and the live region announces the destination. A list remains a valid drop target when it’s empty.

Keyboard interactions
KeyAction
Enter or Space on a move buttonMove to the other list
Enter or Space on a drag handleEnter drag mode and focus the other list
Enter or Escape in drag modeDrop or cancel

Usage guidelines

Do

  • Use names that describe the state, such as Available permissions and Enabled permissions.

Don’t

  • Avoid using the transfer list for reordering items within one collection. Use SortableList for that.