Vitral 0.2.18
Data

PickList

Two lists and the moves between them, with buttons, the keyboard or a double click, and reordering within each.

Import

main.ts
import { PickList } from '@vitral/vue';

Basic

Available skills
  • Design
  • Research
  • Writing
  • Analytics
  • Support
Your skills
  • Engineering
Your skills: Engineering
<script setup lang="ts">import { PickList } from '@vitral/vue';import { ref } from 'vue'; interface Skill {    name: string;    icon: string;} const lists = ref<[Skill[], Skill[]]>([    [        { name: 'Design', icon: 'pencil' },        { name: 'Research', icon: 'search' },        { name: 'Writing', icon: 'file' },        { name: 'Analytics', icon: 'sliders' },        { name: 'Support', icon: 'bell' }    ],    [{ name: 'Engineering', icon: 'grip' }]]);</script> <template>    <PickList v-model="lists" option-label="name" data-key="name" source-header="Available skills" target-header="Your skills" scroll-height="14rem">        <template #option="{ item }">            <span style="display: inline-flex; align-items: center; gap: 0.5rem">{{ (item as Skill).name }}</span>        </template>    </PickList>    <small style="color: var(--vt-text-muted-color)">Your skills: {{ lists[1].map((s) => s.name).join(', ') || 'none' }}</small></template>

API

Read from packages/vue/src/components/PickList/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
optionLabel stringField (dotted path) holding an item's text, for the default template and the announcements.
dataKey stringA field that identifies an item.
sourceHeader stringNames the first list. Defaults to the locale's "Available".
targetHeader stringNames the second list. Defaults to the locale's "Selected".
showSourceControls booleanShow the move buttons beside the first list. Defaults to true.
showTargetControls booleanShow the move buttons beside the second list. Defaults to true.
scrollHeight stringThe lists' height.
disabled boolean—
scrollbar ScrollbarModeThe bars of the boxes this component scrolls inside — `'hover'`, `'always'` or `'native'`. The application's `scrollbar` option by default, which is `'hover'`.

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Emits

EventPayloadDescription
move-to-target event: { items: unknown[] }—
move-all-to-target event: { items: unknown[] }—
move-to-source event: { items: unknown[] }—
move-all-to-source event: { items: unknown[] }—
reorder event: { list: 'source' | 'target'; value: unknown[] }—

Slots

NameSlot propsDescription
option (props: { item: unknown; index: number; selected: boolean; list: 'source' | 'target' })An item's content, in either list.
sourceheader ——
targetheader ——