Transfer List
Dual listbox for moving items between an available and a selected pane, for permission and settings screens.
<arc-transfer-list>Overview
TransferList shows every option in two panes: the ones not chosen on the left ("Available") and the current value on the right ("Selected"). The reader checks items, then moves them across with the buttons between the panes, or moves one item at once with a double-click or Enter. sourceLabel and targetLabel rename the panes, and each pane header shows a live "checked of total" count.
options is an array of { value, label, disabled? } objects, and value is the array of values in the Selected pane, in options order. With searchable, each pane gets its own case-insensitive filter, and the move-all buttons move only what the filter shows. Disabled options are dimmed and can't be moved.
It's form-associated. Give it a name and it submits one entry per selected value, resets with form.reset(), and is disabled by <fieldset disabled>. Both panes follow the WAI-ARIA multi-select listbox pattern, and moves are announced through a polite live region.
Guidelines
Do
- Use it for sets of about 5 to 100 items where the reader picks a subset, such as role permissions or report columns
- Set `searchable` when a pane can hold more than a dozen items
- Keep option labels to one short line so they don't truncate in narrow panes
- Rename the panes with terms from your domain, such as "All permissions" and "Granted"
- Listen to `arc-change` to save the selection. Its detail carries the full value array after every move
Don't
- Don't use it for a handful of options. Use a checkbox group or MultiSelect
- Don't give it thousands of items without narrowing them on the server first. Every option renders
- Don't treat checked items as the selection. Only items in the right pane are the value
- Don't disable options without saying somewhere why they can't be moved
- Don't put two transfer lists side by side. Each one needs the width for its two panes
Features
- Keyboard: one tab stop per pane with a roving tabindex, ArrowUp and ArrowDown, Home and End, Space to check, and Ctrl+A to check every visible item
- After a move, focus stays in the same pane on the nearest remaining item
- The move buttons turn off when there's nothing for them to move
- Below a container width of about 560px the panes stack and the controls turn horizontal
Preview
Usage
This component needs JavaScript. Use the Web Component or a framework wrapper.
<arc-transfer-list
id="permissions"
name="permissions"
searchable
source-label="Available"
target-label="Granted"
></arc-transfer-list>
<script>
const tl = document.getElementById('permissions');
tl.options = [
{ value: 'read', label: 'Read content' },
{ value: 'write', label: 'Write content' },
{ value: 'admin', label: 'Administer', disabled: true },
];
tl.value = ['read'];
tl.addEventListener('arc-change', (e) => {
console.log(e.detail.value);
});
</script>import { TransferList } from '@arclux/arc-ui-react';
const options = [
{ value: 'read', label: 'Read content' },
{ value: 'write', label: 'Write content' },
{ value: 'admin', label: 'Administer', disabled: true },
];
<TransferList
options={options}
value={['read']}
searchable
sourceLabel="Available"
targetLabel="Granted"
onArcChange={(e) => console.log(e.detail.value)}
/><script setup>
import { TransferList } from '@arclux/arc-ui-vue';
const options = [
{ value: 'read', label: 'Read content' },
{ value: 'write', label: 'Write content' },
];
</script>
<template>
<TransferList
:options="options"
:value="['read']"
searchable
source-label="Available"
target-label="Granted"
@arc-change="(e) => console.log(e.detail.value)"
/>
</template><script>
import { TransferList } from '@arclux/arc-ui-svelte';
const options = [
{ value: 'read', label: 'Read content' },
{ value: 'write', label: 'Write content' },
];
</script>
<TransferList
{options}
value={['read']}
searchable
source-label="Available"
target-label="Granted"
on:arc-change={(e) => console.log(e.detail.value)}
/>import { Component } from '@angular/core';
import { TransferList } from '@arclux/arc-ui-angular';
@Component({
imports: [TransferList],
template: `
<arc-transfer-list
[options]="options"
[value]="['read']"
searchable
sourceLabel="Available"
targetLabel="Granted"
(arcChange)="onChange($event)"
></arc-transfer-list>
`,
})
export class PermissionsComponent {
options = [
{ value: 'read', label: 'Read content' },
{ value: 'write', label: 'Write content' },
];
onChange(e: CustomEvent) {
console.log(e.detail.value);
}
}API
namestring''- Form field name. When set, the component submits one form entry per selected value.
disabledbooleanfalse- Disables the whole control, preventing interaction and reducing opacity.
source-labelstring'Available'- Heading for the left (available) pane. Attribute:
source-label. target-labelstring'Selected'- Heading for the right (selected) pane. Attribute:
target-label. optionsArray<{value:string,label:string,disabled?:boolean}>[]- The full universe of items. Items whose value is in
valuerender in the Selected pane; the rest render in Available. valuestring[][]- Values currently in the Selected pane, kept in options order. Updated after every move and emitted via
arc-change. searchablebooleanfalse- Adds a filter input to each pane that narrows that pane only, case-insensitively. Move-all respects the filter.
readonlybooleanfalse- Prevents moving items between panes while the lists stay focusable and filterable; the selected values still submit with the form.
size'sm' | 'md' | 'lg''md'- Control size.
mdis the default;smandlgscale the row height and list panels. formAssociatedbooleantruepropertiesobject{ // flag(), unlike `disabled`. The exclusion in props.js is specifically // about form-associated *platform* semantics: a `disabled` content // attribute that is merely present makes the element actually disabled // per the HTML spec, and formDisabledCallback assigns the property back, // so no converter can win. Neither of these is platform-mapped: // `required` is enforced by _computeValidity() below and `readonly` by // each component's own interaction handlers, so the stock converter buys // nothing here and costs the usual bug: `required="false"` read as true, // blocking submission of a form the author meant to leave optional. // Finding #48's shape, across all 26 form controls at once. required: flag(false), readonly: flag(false), }- Lit merges static properties up the prototype chain, so every consumer
gets these without declaring them.
requiredparticipates in constraint validation below;readonlyreflects for styling and is enforced by each component's interaction handlers (the mixin can't know which gestures mutate state). autoValidatesbooleantrue- Components that run their own constraint-validation logic (pattern checks, range checks) opt out of the automatic required sync by overriding this to false, and own the whole validity flag set instead.
formvalidityvalidationMessagerequiredbooleanfalse
Methods
checkValidity()boolean- Whether the control currently satisfies its constraints, per the native
constraint-validation API. Fires
invalidon the element when it does not, and reports nothing to the user. reportValidity()boolean- As checkValidity(), but also shows the browser's validation message against the control when it fails.
Events
arc-changedetail:{ value: string[] }- Fired after every move with
{ value }: the current array of selected values.
See also
- Multi SelectA dropdown for picking several options, shown as removable chips.
- Sortable ListA list people reorder by dragging a grip handle or with the keyboard, with a line marking where the item will land.
- CheckboxA checkbox with a built-in label and an indeterminate state for "select all" boxes.
- Switch GroupGroups toggle switches under one label and sets their size and disabled state together. Lays them out vertically or horizontally.