Skip to main content

rc-transfer-list

Transfer list that enhances a native <select multiple> into available and selected panes.

The component renders two listboxes and transfer/reorder actions in between. Available options are on the left, and selected options appear on the right. It is an older enterprise/admin UI pattern, but solves the specific problem of multiple selection within a large amount of options.

Modern use cases include user and permissions management tasks, multi-select for columns / fields / filters and list re-ordering.

Use compact when the surrounding layout should stack the available list, actions, and selected list in one column. The component does not switch layout automatically at viewport breakpoints.

Package
@rcarls/rc-transfer-list
Element
<rc-transfer-list>
Native dependency
Requires a native select child
State model
Native select selection
Main events
rc-transfer-list-change

Installation​

npm install @rcarls/rc-webcomponents@next
import '@rcarls/rc-webcomponents/rc-transfer-list/define';

Usage​

Wrap a native <select multiple>. Its selected options form the selected list, in order, so form submission sends the values shown there.

<rc-transfer-list available-label="Available planets" selected-label="Mission route">
<select name="planets" multiple>
<option value="mercury">Mercury</option>
<option value="venus" selected>Venus</option>
<option value="earth">Earth</option>
</select>
</rc-transfer-list>

Live demo​

Accessibility​

Each side is an rc-listbox, named by available-label and selected-label, with its own list navigation and selection. The action buttons are native buttons in an rc-toolbar, so arrow keys move between them. These shortcuts also work while focus is in either list:

KeyAction
Alt+Right ArrowAdds the highlighted available options.
Alt+Left ArrowRemoves the highlighted selected options.
Alt+Up Arrow, Alt+Down ArrowMoves the highlighted selected options up or down.
EnterIn a single-select available list, adds the highlighted option.
DeleteIn the selected list, removes the highlighted options.

Alt+Left and Alt+Right swap in right-to-left text, where the lists swap sides.

Theming​

The default demo mode shows the component without a package theme. Use the shared preview controls on this page to compare inherited, light, and dark color schemes or to apply the optional Material theme only inside the demo frames.

Localization​

Built-in text follows the element's own lang, else <html lang>. Override it with messages, or register it for every instance under rc-transfer-list: available, selected, actions, add, addAll, remove, clear, moveUp, moveDown. See Localization.

API​

Properties​

PropertyMarkupTypeDefaultDescription
multiplemultiplebooleanfalseEnable multi-selection in both lists.
compactcompactbooleanfalseStack the panels and action toolbar into a compact one-column layout.
availableLabelavailable-labelstring | undefinedNot specifiedVisible label for the available list. Defaults to the `available` message.
selectedLabelselected-labelstring | undefinedNot specifiedVisible label for the selected list. Defaults to the `selected` message.
messagesJS property onlyPartial<RCTransferListMessages> | undefinedNot specifiedBuilt-in text overrides; unset keys fall back to registered text, then English.
availableJS property onlyListboxOption[]Not specifiedAvailable/left-hand options derived from unselected `<option>` elements. Setting this property replaces all unselected options in the backing `<select>`. Items whose values already appear in the selected list are skipped to prevent duplicate option values.
selectedJS property onlyListboxOption[]Not specifiedSelected/right-hand options derived from selected `<option>` elements. Setting this property replaces all selected options in the backing `<select>`. Unselected options are left unchanged.
defaultSelectedJS property onlyListboxOption[] | undefinedNot specifiedInitial uncontrolled selected list. Applied before any `selected` write from the host.

Methods​

MethodDescription
addSelected()Adds the highlighted available options to the selected list.
addAll()Adds every available option to the selected list.
removeSelected()Removes the highlighted right-hand options from the selected list.
clearSelected()Clears the selected/right-hand list.
moveSelected(delta: number)Moves highlighted right-hand options by `delta` rows (-1 = up, 1 = down).

Events​

EventDetail typeDescription
rc-transfer-list-changeCustomEventFires when the selected/right-hand list changes.

CSS Custom Properties​

PropertyDefaultDescription
--rc-transfer-list-gapvar(--rc-control-gap, 0.75rem)Gap between panels and the action toolbar
--rc-transfer-list-panel-gapvar(--rc-control-gap, 0.35rem)Gap between a panel label and its listbox
--rc-transfer-list-listbox-min-block-size10remMinimum block size for each listbox
--rc-transfer-list-listbox-bordervar(--rc-border, 1px solid ButtonBorder)Border around each listbox
--rc-transfer-list-listbox-radiusvar(--rc-control-radius, 0.125rem)Corner radius of each listbox
--rc-transfer-list-listbox-bgvar(--rc-surface, Canvas)Background of each listbox
--rc-transfer-list-listbox-colorvar(--rc-field-text, FieldText)Text color of each listbox
--rc-transfer-list-option-gapvar(--rc-item-gap, 0.4em)Gap between option adornments and labels
--rc-transfer-list-option-padding-blockvar(--rc-item-padding-block, 0.3em)Block padding for option rows
--rc-transfer-list-option-padding-inlinevar(--rc-item-padding-inline, 0.75em)Inline padding for option rows
--rc-transfer-list-option-selected-bgvar(--rc-highlight, Highlight)Selected option background
--rc-transfer-list-option-selected-colorvar(--rc-highlight-text, HighlightText)Selected option foreground
--rc-transfer-list-option-hover-bgvar(--rc-transfer-list-option-selected-bg, var(--rc-highlight, Highlight))Hovered/active option background
--rc-transfer-list-option-hover-colorvar(--rc-transfer-list-option-selected-color, var(--rc-highlight-text, HighlightText))Hovered/active option foreground

CSS Parts​

PartDescription
rootRoot layout wrapper. Reflects data-can-move-up/down.
panelShared list panel surface.
available-panelAvailable/left panel. Reflects data-empty and data-has-selection.
selected-panelSelected/right panel. Reflects data-empty and data-has-selection.
labelShared panel label surface.
available-labelLabel for the available panel.
selected-labelLabel for the selected panel.
listboxShared listbox surface.
available-listboxThe available/left `rc-listbox`.
selected-listboxThe selected/right `rc-listbox`.
actionsTransfer action toolbar.
buttonShared action button surface.
add-buttonMoves highlighted available options to the selected list.
add-all-buttonMoves every available option to the selected list.
remove-buttonMoves highlighted selected options back to the available list.
clear-buttonMoves every selected option back to the available list.
move-up-buttonMoves highlighted selected options up.
move-down-buttonMoves highlighted selected options down.