Transfer
A two-panel list with check-to-move; data partitioning and moving logic are done immutably in the core layer. Both panels are role="listbox" (APG listbox pattern).
The value semantics match lh-ui-plus: the controlled value is the list of keys kept on the left (source) panel — a key present in the value sits in the left panel, otherwise it sits in the right panel.
Basic usage
- No data
- Ink wash
- Danqing
- Gongbi
- Blank space
- Xieyi (freehand)
- Seal (disabled)
Current value: (not selected)
import { useState } from 'react'
import { LhTransfer } from '@lh-ui/react'
import type { LhTransferItem } from '@lh-ui/react'
const data: LhTransferItem[] = [
{ key: 'ink', label: 'Ink wash' },
{ key: 'danqing', label: 'Danqing' },
{ key: 'gongbi', label: 'Gongbi' },
{ key: 'blank', label: 'Blank space' },
{ key: 'xieyi', label: 'Xieyi (freehand)' },
{ key: 'seal', label: 'Seal (disabled)', disabled: true },
]
export default function Demo() {
const [value, setValue] = useState<(string | number)[]>([])
return <LhTransfer data={data} value={value} onChange={(next) => setValue(next)} />
}
Transfer Props
| Prop | Description | Type | Options | Default |
|---|---|---|---|---|
| data | Full data set | LhTransferItem[] | — | — |
| value | Controlled value (keys kept on the left panel, equivalent to plus's modelValue) | (string | number)[] | — | — |
| defaultValue | Uncontrolled default value (defaults to an empty array, i.e. everything on the right) | (string | number)[] | — | [] |
| disabled | Disable the whole transfer | boolean | — | false |
| sx | Shorthand layout props | SxProps | — | — |
LhTransferItem
| Prop | Description | Type |
|---|---|---|
| key | Unique key | string | number |
| label | Display text (falls back to the key when missing) | string |
| disabled | Disabled (cannot be checked or moved) | boolean |
Transfer events
| Event | Description | Callback signature | Vue equivalent |
|---|---|---|---|
| onChange | Fired after checked items are moved (new source key list plus the direction) | (keys: (string | number)[], direction: 'left-to-right' | 'right-to-left') => void | @change |
Keyboard interaction
Each panel is a role="listbox" with aria-multiselectable and uses roving tabindex: one tab stop per panel, anchored to the most recently checked item (falling back to the first available item when the anchor is disabled). ArrowUp / ArrowDown move within the filtered list (skipping disabled items, clamped at the ends), Enter / Space toggle the current item, ArrowRight on the left panel / ArrowLeft on the right panel jump focus between panels, and Escape resets focus to the anchor. The header check-all input supports the indeterminate state.
Styles
import '@lh-ui/react/style/transfer'