Vitral 0.2.18
Data

OrderList

A list the reader puts in order, with buttons, the keyboard or drag and drop.

Import

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

Basic

Trip order
  • São PauloBrazil
  • LisboaPortugal
  • LuandaAngola
  • MaputoMozambique
  • PraiaCabo Verde
  • DiliTimor-Leste
Order: São Paulo → Lisboa → Luanda → Maputo → Praia → Dili
<script setup lang="ts">import { OrderList } from '@vitral/vue';import { ref } from 'vue'; const cities = ref([    { name: 'São Paulo', country: 'Brazil' },    { name: 'Lisboa', country: 'Portugal' },    { name: 'Luanda', country: 'Angola' },    { name: 'Maputo', country: 'Mozambique' },    { name: 'Praia', country: 'Cabo Verde' },    { name: 'Dili', country: 'Timor-Leste' }]);const selection = ref([]);</script> <template>    <OrderList v-model="cities" v-model:selection="selection" option-label="name" data-key="name" header="Trip order" scroll-height="16rem" style="max-width: 28rem">        <template #option="{ item }">            <div style="display: flex; justify-content: space-between; width: 100%">                <span>{{ (item as { name: string }).name }}</span>                <small style="color: var(--vt-text-muted-color)">{{ (item as { country: string }).country }}</small>            </div>        </template>    </OrderList>    <small style="color: var(--vt-text-muted-color)">Order: {{ cities.map((c) => c.name).join(' → ') }}</small></template>

API

Read from packages/vue/src/components/OrderList/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.
header stringThe list's title; it names the list. Without one, name it with `aria-label`.
dragdrop booleanLet items be dragged to a new place. Defaults to true.
showControls booleanShow the move buttons. Defaults to true.
scrollHeight stringThe list's 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
reorder event: { originalEvent?: Event; value: unknown[]; direction: 'up' | 'down' | 'top' | 'bottom' | 'drop' }—

Slots

NameSlot propsDescription
option (props: { item: unknown; index: number; selected: boolean })An item's content.
header —Replaces the title.