Skip to main content

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​

Check and move
0 / 6
  • No data
6 / 6
  • 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​

PropDescriptionTypeOptionsDefault
dataFull data setLhTransferItem[]——
valueControlled value (keys kept on the left panel, equivalent to plus's modelValue)(string | number)[]——
defaultValueUncontrolled default value (defaults to an empty array, i.e. everything on the right)(string | number)[]—[]
disabledDisable the whole transferboolean—false
sxShorthand layout propsSxProps——

LhTransferItem​

PropDescriptionType
keyUnique keystring | number
labelDisplay text (falls back to the key when missing)string
disabledDisabled (cannot be checked or moved)boolean

Transfer events​

EventDescriptionCallback signatureVue equivalent
onChangeFired 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'