Sortable

Reorders a list by dragging: rows of a group, table rows, images, tags and cards. The order changes on the drop.

Examples

Rows

Rows with a handle

Stacked rows

Different controls

Table

Images

Tags

Cards

API

PropTypeDefaultDescription
valueunknown[]—The list, in the order of the children. Bind with v-model:value
layout'list' | 'grid'listlist for rows one under another, grid for items that stand side by side
asstring | ComponentdivElement to render, such as TableBody for table rows
disabledbooleanfalseTurns dragging off
handlesbooleantrue in a table, otherwise falseShows the grips of SortableHandle. A hidden grip still takes the keyboard, and the item drags from anywhere but a control

Events: update:value and change fire with the new order after a drop. The default slot holds the items: one direct child per entry of value, keyed by the entry and not by its index.

SortableHandle is the grip of an item. It renders a button, takes its attributes, and shows GripVertical unless its slot has content.

PropTypeDefaultDescription
aria-labelstringReorderName of the handle for assistive technology

The chip takes its text from data-sortable-label on the item, then from an element with that attribute or a label inside it, then from its first text. It shows the first img of the item.

Styling

Sortable reads these component tokens. Override them at any scope to restyle it:

  • --sortable-chip-max-width: chip max width (default 18rem)
  • --sortable-chip-radius: chip radius (default 14px)
  • --sortable-chip-image-size: picture in the chip (default 40px)
  • --sortable-chip-shadow: chip shadow
  • --sortable-chip-z-index: chip layer (default 100000)
  • --sortable-handle-size: handle size (default 32px)
  • --sortable-handle-icon-size: grip size (default 16px)
  • --sortable-handle-inset: handle offset from the edge of a row (default 8px)
  • --sortable-handle-color: grip color (default var(--color-text-tertiary))
  • --sortable-handle-color-hover: grip color on hover (default var(--color-text-secondary))
  • --sortable-line-size: line thickness (default 2px)
  • --sortable-line-color: line color (default var(--color-background-info-solid))
  • --sortable-slot-inset: slot inset in a list (default 8px)
  • --sortable-slot-radius: slot radius (default 12px)
  • --sortable-slot-background: slot under the pointer (default var(--color-background-info-soft))
  • --sortable-slot-background-away: slot once the pointer left it (default var(--color-surface-tertiary))